Single Ruby Gem that parses BOTH xlsx and xls Excel files? - ruby-on-rails

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.

Related

creating xls files with images in ruby (UNIX)

I am trying to create a xls file which includes charts with Ruby. We run ruby on rails in Unix environment(Debian). We currently use Spreadsheet gem. But this gem doesn't seem to have chart capability. Looks like Win32ole gem is for Windows only. Axlsx is more what I need but it works with xlsx files. Anyone know a better way of doing this? Thanks!
The writeexcel gem (github) supports xls and charts.

Parse doc and xls files in ruby

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

Parsing data from excel sheet

Any gem or plugins in ruby on rails which will read the data from excel sheet.
Try Spreadsheet GEM. It provides facility to read xls file. You can also try Roo.

Rails: export to .xlsx (Office 2007) spreadsheet

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

Prawn gem: How to create the .pdf from an *existing* file (.xls)

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.

Resources