aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP
MIT License
163 stars 31 forks source link

Bugfix: Linux not identifying .xlsx as correct mimetype... #34

Closed AzzaAzza69 closed 1 year ago

AzzaAzza69 commented 1 year ago

In order to differentiate from regular .zip files, the mimetype looks for files added to the .xlsx in order (as per Office 2007+), in particular: [Content_Types].xml needs to be first followed by at least one file in the xl/ folder...

reference: https://stackoverflow.com/questions/7274030/detect-excel-xlsx-file-mimetype-via-php

Can you tweak the saveToFile function?

PS. It may be more prudent to move the exception for "No worksheets defined" BEFORE the file_exists/unlink check as no worksheets will result in the file being deleted without creating any output! <Maybe even just before the $zip->close() in case any other problems/exceptions cause the .zip not to be created?>

aVadim483 commented 1 year ago

Thanx for the link, I'll explore this pronlem

aVadim483 commented 1 year ago

The order of writing entries to the XLSX-file has been changed in v.4.7 And mimetype must be correct now

AzzaAzza69 commented 1 year ago

Fixed :)