Rails Gem" Axlsx" - 重命名工作簿

时间:2016-06-01 11:52:17

标签: ruby-on-rails ruby-on-rails-3 axlsx

我的工作簿总是命名为我的模板" invoices_generate.xlsx"。 我该如何重命名这个文件?

模板" invoices_generate.xlsx.axlsx" :

wb = xlsx_package.workbook

    wb.add_worksheet(:name => "Beleg") do |sheet|  

    .
    .
    .

    sheet.column_widths 2 , 11, 11, 11, 11, 23, 3

    end

1 个答案:

答案 0 :(得分:1)

你是否也添加了axlsx_rails gem?如果是这样的话:

wb = xlsx_package.workbook
wb.add_worksheet(name: "Beleg") do |sheet|
  sheet.column_widths 2 , 11, 11, 11, 11, 23, 3
end

有关详细信息,请参阅https://github.com/straydogstudio/axlsx_rails#template,如果这不起作用,请尝试从控制器操作中设置文件名,呈现xlsx模板,如下所述:https://github.com/straydogstudio/axlsx_rails#file-name