caxlsx / caxlsx_rails

A Rails plugin to provide templates for the axlsx gem
MIT License
735 stars 84 forks source link

disposition: 'inline' is not working #142

Closed ghost closed 2 years ago

ghost commented 4 years ago

in gem file

gem 'caxlsx'
gem 'caxlsx_rails'

In controller

render xlsx: @report.name<<'_'<<Time.now.strftime('%m-%d-%Y-%H%M%S'), template: "admin/my_reports/show.xlsx.axlsx", disposition: 'inline'

The report is generated correctly BUT it is downloaded instead of rendered in browser (Chrome)

straydogstudio commented 4 years ago

@petervandeput My memory is a bit rusty here, but I think there is no way to force a browser into using the disposition. Can you use the developer tools to make sure the header is coming through in the request?

ghost commented 4 years ago

it does turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6 Resource interpreted as Document but transferred with MIME type application/xlsx: "http://localhost:3000/admin/my_reports/2".

ghost commented 4 years ago

Content-Transfer-Encoding: binary Content-Type: application/vnd.ms-excel

straydogstudio commented 4 years ago

It should be "Content-Disposition: inline". Are you saying that it is there?

You could manually set it as well: response.headers['Content-Disposition'] = 'inline' or response.headers['Content-Disposition'] = 'inline; filename="my_new_filename.xlsx"' before your render statement.

What version of rails, caxlsx, and caxlsx_rails are you using?

straydogstudio commented 4 years ago

Note if you use the response.headers statement you'll want to pass the disposition to render as well.

ghost commented 4 years ago

sorry but didn't work

straydogstudio commented 3 years ago

@petervandeput Did you ever have any luck with this?