Is there any plugin in Ruby that converts CSV file onto Excel. I did little Google but all I found was converting Excel file into CSV. I know few gems which I can tweak a little and use to convert Excel to CSV but I need to know if anyone has done that before.
相关问题
- sqlyog export query result as csv
- Excel sunburst chart: Some labels missing
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
相关文章
- Ruby using wrong version of openssl
- How to read local csv file in client side javascri
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- Get column data by Column name and sheet name
If you don't found any gem for convert CSV to EXCEL then you can try to find two gems separately
For those seeing this currently, the syntax changed a bit in these eight years. The following worked perfectly for me, based on the previous answer (recopied here for the sake of your copy-and-paste habits):
I.E.: FasterCSV is now just CSV and true for :bottom is deprecated
According to this post, the spreadsheet gem is a possibility. It looks like this is a very popular gem. Check it out. Example:
According to this post, write_xlsx is a possibility.
I've used the Apache POI library with JRuby to export xls files. Here's a quick example.
Some useful methods for formatting POI spreadsheets are
sheet.createFreezePane(0,1,0,1)
wb.setRepeatingRowsAndColumns(0, -1, -1, 0, 1)
sheet.setColumnWidth(i, 100 *256)
sheet.autoSizeColumn(i)
, but beware, if you're running in headless mode, you have to calljava.lang.System.setProperty("java.awt.headless", "true")
You can also use Win32ole on Windows, if you have Excel installed
Some useful methods for formatting with Excel are
xl.Rows(1).Font.Bold = true
ws.Cells.EntireColumn.AutoFit
Yet another option is to write directly to Microsoft's XML Spreadsheet format, as Ryan Bates at Railscasts.com does at the end of his Exporting CSV and Excel episode.
This gem looks promising, too.
The easy way is:
,
(comma) to a tab\t
.xls