我正在尝试读取ruby中的excel文件,然后获取数据并将其插入到mysql数据库中。我正在使用电子表格:: excel和mysql gems。出于某种原因,我似乎无法使用电子表格gem打开文件进行阅读...这是我的代码
require 'rubygems'
require 'spreadsheet'
require 'mysql'
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet.open '/home/data/teams.xlsb'
b1 = book.worksheet('team1')
当我运行脚本时,我得到了这个奇怪的错误
/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
我在某处读到这个gem可能无法支持.xlsb文件。我不知道这是不是真的,但如果是的话有人可以告诉我如何绕过它,或者是否有其他错误?我完全迷失了,并希望得到任何有关此错误的帮助。谢谢