Roo 的错误。任何用于解析 .ods 文件的 gem

发布于 2024-11-16 11:10:21 字数 1854 浏览 0 评论 0原文

我正在尝试使用 roo gem 来解析 Openoffice 电子表格。 时收到以下错误

但是,我在启动 localhost /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo/openoffice.rb:3:in `require ': 没有这样的文件可以加载 -- zip/zipfilesystem (LoadError

) /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo/openoffice.rb:3:in `'

来自 /home/raison/.rvm/gems/ ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo.rb:68:在`require'

中/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo.rb:68:in `'

来自 /home/raison/.rvm/gems/ruby- 1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:在“require”

中 块(2 级)”中

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:在“require中的 “每个”

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66 :来自 /home/raison/.rvm/gems 的 /ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in 的`block in require'

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'

中 “require”

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55 :来自 /home/raison/.rvm/gems 的 /ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'

来自 /home/raison/anna/config/application.rb:7:7:in

来自 /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib 的 /rails/commands.rb:28:在`require'

中 “块”中

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:28:在来自 /home/raison/.rvm/ 的 gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:27:in “tap”

来自 /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:27:in

来自 script/rails:6 的 `require' 中

:在script/rails:6 的

:在 `' 中我已经安装了 ruby​​zip。有人可以帮我吗?另请建议一些用于解析 .ods 文件的替代 gem。

I am trying to use the roo gem to parse an Openoffice spreadsheet. However I am getting the following error while beginning my localhost

/home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo/openoffice.rb:3:in `require': no such file to load -- zip/zipfilesystem (LoadError)

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo/openoffice.rb:3:in `'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo.rb:68:in `require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/roo-1.9.3/lib/roo.rb:68:in `'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'

from /home/raison/anna/config/application.rb:7:in `'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:28:in `require'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:28:in `block in '

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:27:in `tap'

from /home/raison/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:27:in `'

from script/rails:6:in `require'

from script/rails:6:in `'

I already have rubyzip installed. Can anyone help me out here? Also please suggest some alternate gems for parsing .ods files .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恋竹姑娘 2024-11-23 11:10:21

在 Gemfile

gem 'rubyzip' 中,:require => 'zip/zip 文件系统'

In Gemfile

gem 'rubyzip', :require => 'zip/zipfilesystem'

美胚控场 2024-11-23 11:10:21

Rspreadsheet 允许您读取、修改和写入 ods 文件。这是其基本用法的示例

require 'rspreadsheet'

# initialization
book = Rspreadsheet.open('./test.ods')
sheet = book.worksheets(1)

# get value of a cell B5 (there are more ways to do this)
sheet.B5                       # => 'cell value'
sheet[5,2]                     # => 'cell value'
sheet.rows(5).cells(2).value   # => 'cell value'

# set value of a cell B5
sheet.F5 = 'text'
sheet[5,2] = 7
sheet.cells(5,2).value = 1.78

# working with cell format
sheet.cells(5,2).format.bold = true
sheet.cells(5,2).format.background_color = '#FF0000'

# calculating sum of cells in row
sheet.rows(5).cellvalues.sum
sheet.rows(5).cells.sum{ |cell| cell.value.to_f }

# iterating over list of people and displaying the data

total = 0
sheet.rows.each do |row|
  puts "Sponsor #{row[1]} with email #{row[2]} has donated #{row[3]} USD."
  total += row[3].to_f
end
puts "Totally fundraised #{total} USD"

# saving file
book.save
book.save('different_filename.ods')

该项目正在积极开发中,我在我的项目中使用它。欢迎任何评论。如果您要迁移某个功能,您可以填写请求,它将被实现。

Rspreadsheet allows you to read, modify and write ods files. Here is the example of its basic usage

require 'rspreadsheet'

# initialization
book = Rspreadsheet.open('./test.ods')
sheet = book.worksheets(1)

# get value of a cell B5 (there are more ways to do this)
sheet.B5                       # => 'cell value'
sheet[5,2]                     # => 'cell value'
sheet.rows(5).cells(2).value   # => 'cell value'

# set value of a cell B5
sheet.F5 = 'text'
sheet[5,2] = 7
sheet.cells(5,2).value = 1.78

# working with cell format
sheet.cells(5,2).format.bold = true
sheet.cells(5,2).format.background_color = '#FF0000'

# calculating sum of cells in row
sheet.rows(5).cellvalues.sum
sheet.rows(5).cells.sum{ |cell| cell.value.to_f }

# iterating over list of people and displaying the data

total = 0
sheet.rows.each do |row|
  puts "Sponsor #{row[1]} with email #{row[2]} has donated #{row[3]} USD."
  total += row[3].to_f
end
puts "Totally fundraised #{total} USD"

# saving file
book.save
book.save('different_filename.ods')

The project is under active developments and I use it in my projects. Any comments are welcomed. If you are migging a feature, you may fill in the request and it will be implemented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文