I am trying to render a xlsx
file. But I keep getting a 406/UnknowFormat
. I have done the right setup, maybe im missing something?
Rails 4.2 app
gem 'axlsx'
gem "axlsx_rails"
gem 'zip-zip'
config/initializers/mime
Mime::Type.register "application/xlsx", :xlsx
controller
respond_to do |format|
format.xlsx { render xlsx: "create", template: "api/reports/create" }
end
views/api/reports/create.xlsx.axlsx
wb = xlsx_package.workbook
wb.add_worksheet(name: "Reports") do |sheet|
sheet.add_row [@report_name]
end
format.xlsx { render xlsx: "create", filename: "api/reports/create.xlsx" }
– FaroCompleted 406 Not Acceptable in 10038ms ActionController::UnknownFormat (ActionController::UnknownFormat): app/controllers/api/reports_controller.rb:12:in 'create'
– Marsupialaxlsx_rails
defines the xlsx mime type. You shouldn't have to. – Broeder