-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Cloning worksheet makes corrupted Xlsx #1516
Comments
Appeared in v 1.13. Previous release is not affected. |
This has to do with the change to ZipStream. Before and after, because of the clone, PhpSpreadsheet tries to write printerSettings1.bin to xl/printerSettings/. With the PHP Zip class, only one copy of this file is retained. But, with ZipStream, both copies are retained (I didn't even know that was possible), and that is the problem that Excel is having. I am not familiar with ZipStream, |
Omitted one word above. |
Strange that two copies in the same path, with the same name, are being retained. Is that even a valid ZIP? |
Made this work by downgrading to v.1.11 for now. Lets wait for fixed release |
@kimbarcelona01 Unfortunately, version 1.11 as well as 1.12 have a bug regarding the Drawer which is fixed in 1.13 |
This problem is that ZipStream, in contrast to ZipArchive, is saving 2 files with the same path. I have opened an issue with ZipStream, who agree that this appears to be a bug. For the case in question, PhpSpreadsheet is attempting to save a file with the same path twice (and unexpectedly succeeding) because of a clone operation. This fix attempts to rectify the problem by keeping track of all the paths being saved in the zip file, and not attempting to save any duplicate paths. The problem case attempted to save printersettings1.bin twice, but there are other possible exposures, e.g. by cloning a sheet with a drawing.The new test cases clone an existing sample which has both printer settings and drawings.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Fixed by PR #1530 in June 2020. |
This is:
What is the expected behavior?
With old versions of PHPSpreadsheet I was able to clone worksheets (as in the tutorial) and I was able to edit it correctly. For example if I opened an Xlsx file with one template worksheet I was able to clone it N times and every worksheet had different values.
What is the current behavior?
Now, if I try to clone a worksheet and save the Xlsx file it results corrupted.
What are the steps to reproduce?
Example file:
ReportStructure.xlsx
Code:
Screen:

If I press "Si" (Yes), Excel crash
Which versions of PhpSpreadsheet and PHP are affected?
SpreadSheet: 5c18bb5 (1.13)
PHP: 7.3
The text was updated successfully, but these errors were encountered: