Rails Gem "Axlsx" - 重命名工作簿
Rails Gem "Axlsx" - Rename Workbook
我的工作簿总是像我的模板一样命名 "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
您是否也添加了 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 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
供将来参考:在控制器中,在生成工作簿的函数上
def index
@users = User.all
render xlsx: 'export', filename: 'my_new_filename.xlsx' //Render with export and naming the file
respond_to do |format|
format.html
format.xlsx
end
end
我的工作簿总是像我的模板一样命名 "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
您是否也添加了 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 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
供将来参考:在控制器中,在生成工作簿的函数上
def index
@users = User.all
render xlsx: 'export', filename: 'my_new_filename.xlsx' //Render with export and naming the file
respond_to do |format|
format.html
format.xlsx
end
end