Closed PrinzJuliano closed 5 years ago
It's usually not firefox that identifies it by mime type, but the web server that appends a header to the file when it is downloaded. For instance apache: https://httpd.apache.org/docs/2.4/mod/mod_mime_magic.html These modules guess the mime type based on the bytes it is expecting to see. The Excel/XLSX format is a zipped format. So its no surprise that these spreadsheets are showing up as zip archives.
However, the way to mitigate that in a web application you control is by using php to append your own header, for example, example.php
has
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
I was already aware of this workaround. But shouldn't the library create zip files identified by linux to be a spreadsheet when it is?
cat /etc/mime.types |grep xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
https://stackoverflow.com/questions/29017725/how-do-you-change-the-mime-type-of-a-file-from-the-terminal#29019569 In linux, it uses a combination of file extensions and magic bytes to determine the file type. So possibly you are not creating files of .xlsx extension, or xlsx is not found in your /etc/mime.types file.
I happen to notice that files created using the XLSXWriter are not correctly identified by the Linux file command (using version 5.30+).
When creating files in Excel as xlsx (either Strict Open XML or the Excel format) the MIME Type is correctly identified as
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
as it should.But files created by this Library are identified as plain zip files with the MIME type set to
application/zip
.This has some issues with automatic file type identification, as Firefox will identify this file as common zip file rather than a spreadsheet.