我正在尝试将电子表格中的值导入表格中。我将每一行的新记录添加到一个数组,然后导入该数组。我的代码如下:
def import(path)
spreadsheet = Roo::Spreadsheet.open(path+"Data.xlsx")
sales = spreadsheet.sheet('Accounts')
sales = sales.parse(headers: true)
accounts = []
sales.each do |row|
a = HM::NewBusiness.new
a.dealer_id = row["Dlr #"]
a.dealer_name = row["Dealer Name"]
a.duns = row["Duns Name"]
a.industry = row["Type"]
a.volume_2016 = row["volume_2016"]
a.volume_2017 = row["volume_2017"]
a.volume_2018 = row["volume_2018"]
a.volume_2019 = row["volume_2019"]
accounts << a
end
pp accounts
HM::NewBusiness.import(accounts)
end
但是,当我运行import
时,我得到:
TypeError: no implicit conversion of String into Array
我不知道我要去哪里。任何帮助将不胜感激。
答案 0 :(得分:0)
弄清楚了。问题是我恰巧将方法本身命名为“导入”。简而言之是1d10t错误。