gpt4 book ai didi

ruby-on-rails-4 - 导入 .xlsx 文件扩展名时出现 ArgumentError : wrong number of arguments (3 for 1. .2)

转载 作者:行者123 更新时间:2023-12-03 21:33:34 26 4
gpt4 key购买 nike

我在导入 excel 文件时遇到问题,当扩展名为 .xls 时,它可以正常工作,但是当扩展名为 .xlsx 时,它会给出参数错误。

def open_spreadsheet(file)

case File.extname(file.original_filename)
when ".csv" then Roo::Csv.new(file.path, nil, :ignore)
when ".xls" then Roo::Excel.new(file.path, packed: nil, file_warning: :ignore)
when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
else raise "Unknown file type: #{file.original_filename}"
end
end

最佳答案

尝试

 Roo::Excel.new(file.path, packed: false, file_warning: :ignore)

关于ruby-on-rails-4 - 导入 .xlsx 文件扩展名时出现 ArgumentError : wrong number of arguments (3 for 1. .2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30908403/

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