ruby-on-railsruby-on-rails-3axlsx

Rails Gem "Axlsx" - Rename Workbook


My workbook always named like my template "invoices_generate.xlsx". How can i rename this File ?

Template "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

Solution

  • Do you have the axlsx_rails gem added as well? If so:

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

    See https://github.com/straydogstudio/axlsx_rails#template for more details and if that doesn't work try setting the filename from the controller action rendering the xlsx template as described here: https://github.com/straydogstudio/axlsx_rails#file-name