Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Content-Type header for exported XLSX #810

Closed
tchamberlin opened this issue Jun 15, 2021 · 1 comment
Closed

Incorrect Content-Type header for exported XLSX #810

tchamberlin opened this issue Jun 15, 2021 · 1 comment

Comments

@tchamberlin
Copy link

Content-Type header for exported .xlsx files is incorrectly set to application/vnd.ms-excel. This causes e.g. Firefox to incorrectly indicate the file type of the download as "Microsoft Excel 97-2003 Worksheet". It also results in the following error when opening directly in Excel (at least for Windows 10/Firefox/Excel 2019): "The file format and extension of 'table.xlsx-1.xls' don't match. The file could be corrupted or unsafe. ...". The files do open after that, but the error is a bit unsettling.

The MIME type of the resultant file is correct:

$ file --mime-type -b table.xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

The fix here is to change this line to indicate the correct content type of application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.

I've tested the above change, and it behaves as expected. I'm happy to open a PR if that is helpful

Thanks!

@jieter
Copy link
Owner

jieter commented Jun 15, 2021

Thanks for the report, a pull request is very welcome.

@jieter jieter closed this as completed in 51a1101 Aug 9, 2021
Alirezaja1384 pushed a commit to Alirezaja1384/django-tables2 that referenced this issue Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants