i am trying to read an excel file in ruby and then take the data and insert it into a mysql database. I am using the spreadsheet::excel and mysql gems. for some reason i cannot seem to be able to use the spreadsheet gem to open the file for reading... this is my code
require 'rubygems'
require 'spreadsheet'
require 'mysql'
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet.open '/home/data/teams.xlsb'
b1 = book.worksheet('team1')
i get this weird error when i run the script
/usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:376:in `validate!': OLE2 signature is invalid (Ole::Storage::FormatError)
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:368:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:110:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:110:in `load'
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:77:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:83:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:83:in `open'
from /usr/local/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.8/lib/spreadsheet/excel/reader.rb:1144:in `setup'
from /usr/local/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.8/lib/spreadsheet/excel/reader.rb:121:in `read'
from /usr/local/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.8/lib/spreadsheet/excel/workbook.rb:32:in `open'
from /usr/local/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.8/lib/spreadsheet.rb:62:in `open'
from /usr/local/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.8/lib/spreadsheet.rb:68:in `open'
from sizes_importer2.rb:7
i read somewhere that this gem might not be able to support the .xlsb files. i do not know if this is true or not but if it is can someone tell me how to go around it, or if there is something else wrong? i am utterly lost and would appreciate any help with this error. thank you
Did you already take a look to roo? -> http://rubygems.org/gems/roo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With