Took over an existing Rails 2.3.x app. Need to export some data to xlsx format(Excel 2007).
Unfortunately I cant use plain XLS format as it has a limit of 256 columns per sheet. The data the app exports goes beyond that limit.
Are there any existing gems/plug-ins that can generate XLSX files?
I have google-ed for answers, but nothing worked so far.
I have tried installing simple_xlsx_writer gem, and did the usual gem.config "simple_xlsx_writer" but it kept complaining that it couldn't find the required gem. (e.g. "Missing these required gems: simple_xlsx_writer "). Which is weird as I have it installed.
Looked at roo gem, but it only has the ability read xlsx files. So not good.
Open to any other suggestions so as long as the data can be opening in Excel.
Thanks in advance.
Have you seen the AXLSX Gem? You may have to require you database adapter manually and build the export by still possible. This can an entire workbook sheets, charts, etc. The only caveat I found is that charts cannot be their own sheet.
https://github.com/randym/axlsx
Related
I have some .xslm files in my project which I have to edit. My application is written in Rails. I know macro enabled files can not be edited with rubyXL or roo gem, somehow I have to edit them using Ruby/Rails gems or any tool which can be incorporated within Rails app. The application is hosted on AWS, does aws have any tool to do the same ? Plus the requirement is the macros be retained.
It turns out it is not possible to edit macro enabled excel sheets (.xlsm) files in Rails. Even though you tweaked the file somehow, MS Office will treat it as a corrupt file.
I'm coming across transferring and old app to a new one, some of the reports are generated by some very old desktop app running on old xls files, the new app is build with rails 3.x but the only problem I have is that it keeps on getting an OLE Signature error, I tried parsing the files manually via excel to xlsx and all the rails xls gems start reading them. What would be the best way to handle old xls files?
Are there actually gems that read very old xls files, I've already tested roo, spreadsheet, rubyXL (i can't get simple-spreadsheet to work due to version conflicts with roo-xls and spreadsheet requirements)
Gem that would allow me to simply re-parse the file as an xlsx file and let the latest gems read them from there on.
Take a look at this gem https://github.com/roo-rb/roo-xls.
Taken from README.
This library extends Roo to add support for handling class Excel files, including:
.xls files
.xml files in the SpreadsheetML format (circa 2003)
In my rails application, I need to upload some doc/xls files and parse its structure and get information. How can I get data from *.doc or *.xls in maybe xml format or anything else that I can read and parse?
You can parse different types of spreadsheets using the Roo gem. It supports:
OpenOffice
Excel
Google spreadsheets
Excelx
LibreOffice
CSV
From my experience it has some issues with parsing .xls files, however parsing .xlsx files is good.
As for .doc files, you may try using msworddoc-extractor gem or try one of the solutions proposed here.
Update: working with *.docx files - docx and docx-html
Have you seen the Nokogiri gem? http://nokogiri.org/
Very useful for xml parsing
The spreadsheet gem is nice for excel and csv files.
https://github.com/zdavatz/spreadsheet
I'm a bit frustrated with the gems out there. It seems like each one does one thing well but not others.
roo parses both xlsx and xls however it doesn't seem to read certain fields correctly and isn't working in each case I need it to.
spreadsheet gem doesn't parse xlsx
rubyXL doesn't parse xls files
Any other suggestions?
Thanks
I would just combine the rubyXL gem and the spreadsheet gem if you're happy with the individual results both provide.
Can anybody show me (maybe copy/paste a simple code example) how to create the .pdf file from an existing (.xls) file, using the Prawn gem? (Basically, I'd need the command that "opens" the existing file.)
(I'm asking because the Prawn documentation (http://prawn.majesticseacreature.com/docs/) seems to be gone since quite a while - it's not even usable via Google cache...)
Thanks a lot for any help with this!
Tom
I'd suggest that you break the problem down.
Can you read xls with Ruby? Possibly, but it's flaky at best. However, you can easily read csv, and xls exports nicely to that format.
Can you write a 'table' of values to a prawn pdf? Yes
So, (almost) all you need is a little program that can parse a csv file into a prawn-friendly table-structure and then hand it off to Prawn for generation.
Turns out the Prawn gem cannot handle existing files...
Prawn can be used to render content on top of a PDF. You're talking about .xls, a completely different format.