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.
Share
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 = truews.Cells.EntireColumn.AutoFitYet 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.