ruby on rails - 读取excel文件

时间:2018-05-14 12:35:01

标签: ruby-on-rails ruby roo

我有以下错误:

ArgumentError (ArgumentError):
plugins/timemanagement/app/controllers/time_controller.rb:24:in `new'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

并且找不到错误的原因,那是我的代码:

spreadsheet = Roo::Spreadsheet.open(File.open(tmpfile))

header = spreadsheet.first_row
spreadsheet.last_row.each do |i| 
  row = Hash[[header, spreadsheet.row(i)].transpose]
  product = find_by(id: row["id"])
  product.attributes = row.to_hash
  logger.info product
end
你可以帮忙吗?

这是一个Redmine插件,我在lib roo上写道。 require 'roo'也包含在Controller的顶部

0 个答案:

没有答案