gpt4 book ai didi

mysql - ruby excel 阅读器,电子表格 gem

转载 作者:可可西里 更新时间:2023-11-01 06:47:14 24 4
gpt4 key购买 nike

我正在尝试读取 ruby​​ 中的 excel 文件,然后获取数据并将其插入 mysql 数据库。我正在使用 spreadsheet::excel 和 mysql gem。出于某种原因,我似乎无法使用电子表格 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 文件。我不知道这是不是真的,但如果是的话,有人可以告诉我如何绕过它,或者是否还有其他问题?我完全迷路了,希望对这个错误有任何帮助。谢谢

最佳答案

您已经看过 roo 了吗?-> http://rubygems.org/gems/roo

关于mysql - ruby excel 阅读器,电子表格 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7280802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com