phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Uploading Excel file sometimes results in corrupted document

Open Buyur opened this issue 1 year ago • 2 comments

Have been using phpSPO for a while and its working fine except for excel files produced using phpoffice\phpspreadsheet. When I use the example code to upload sometimes when trying to then read the file in Excel from SP its marked as corrupted. If I download the file generated directly from our server and then drag and drop into SP I can see that the filesize is always larger.

I have tried everything including the session and chunk methods but no difference. Sometimes it does work if we re-run the same job over an over until we get a working version in SP but this needs to be 100%.

I've looked into content-type, size, format (XLS or XLSM) and there doesnt seem to be any pattern or obvious cause after hours and hours of testing and trying. Even switched to another server, versions of PHP (7.2, 7.4) and no change. The file is UTF-8 when generated and any other distribution via email or FTP results in a file with no issues.

If anyone can shed any light, suggestion or next place to look I would be eternally grateful as SP is key to distribution of these files (most of our Excel sheets are reporting).

Buyur avatar Mar 31 '23 11:03 Buyur