-
Notifications
You must be signed in to change notification settings - Fork 3.6k
column width lost on load and save with Xlsx #4416
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
Comments
Your title suggests that you are having problem with Xlsx, but you have uploaded an Ods file. Can you please upload the Xlsx file with which you are having a problem? Also, you say you are using ireadfilter. Can you share your ireadfilter code? As for what I have been able to do with the file you uploaded - I opened it in LibreOffice and saved it as Excel. This seems to have been a very inefficient operation - the ods file is 22.7 kilobytes, but the Excel file is 2.62 megabytes. Excel offers me the opportunity to clean up the file, and, when I do that, we're back down to 25.6 Kb. At any rate, when I load and save either version of the file (the big one takes much longer), the column widths appear to be preserved correctly. Perhaps the fact that I don't have a problem is because I'm missing the ireadfilter code. |
as i described, the file is beeing converted using libreOffice through PHP anyway, here is the converted file, that is beeing used after the converting process in phpspreadsheet. i also noticed, that the file is getting very big with the convert. i dont know why. but the loss of the column width happens not within libreoffice (at least i didnt check that) but when you load it with phpspreadsheet and save it afterwards, the column width will be gone, but as i said, only if i use the IReadFilter. |
As expected, my load and save of your newly-uploaded file using PhpSpreadsheet preserves column widths. You say you were using an ireadfilter. Perhaps that accounts for the difference. Please share your ireadfilter code. |
this is the code: class ProtocolFilter implements IReadFilter { |
Thank you for supplying the code. I am able to duplicate your problem when I use it, and will investigate. |
So far, I am not able to duplicate your result on a small version of your spreadsheet. I will need to figure out why there is a difference. |
Fix PHPOffice#4416. A peculiar problem indeed. PhpSpreadsheet has been considering a column to be filtered if any cell in the column is filtered and does not preserve the column width if that is the case. It should consider the column not filtered if any cell in the column is not filtered, and consider it filtered only if there are no cells to which that applies. At least, that's how I think it should work, and this change doesn't break any existing tests, and solves this issue.
i can imagine, that there are some cell-formation-settings defined, that applies to the ENTIRE (endless?) sheet, which cause somehow the problem - but it's just an idea. |
If you can test against PR #4423, please do so. |
thanks for this super fast fix! |
One possible approach is:
Then require newdirectoryname/vendor/autoload.php in your test script. |
thanks alot! i confirm, the bug is fixed! with the new code, the column width remains how it should. thanks alot! |
Thank you for confirming. I will merge the PR into master later today. |
its my first bugreport on github, so please dont judge if something is wrong here.
when loading a specific xlsx file and using a ireadfilter the columnwidth gets lost. i dont know what exactly causing the problem, but i will add an example xlsx-file.
if i open libreoffice, pressing STRG+A to select everything, then deselect my necessary content with SHIFT, click on first row, secon click on last row that i need, and then rightclick on all remaining selected rows, delete rows, and i try then to load and save, the problem is gone!
one more information, i convert the attached ods-file with libreoffice to xlsx.
broken.ods
hope this helps!
The text was updated successfully, but these errors were encountered: