Created attachment 39351 [details] Tab generaged by 5.2.3 (expected) and tab generated by 5.2.4 My OS is Win11 org.apache.poi.ss.usermodel.Sheet.autoSizeColumn 5.2.3 ------------Before resize column 0, the column width is 2048 ------------After resize column 0, the column width is 4462 5.2.4 ------------Before resize column 0, the column width is 2048 ------------After resize column 0, the column width is 3718
I think this is related to https://github.com/apache/poi/pull/541.
Thanks for your quick response! I'm wondering in which release would the fix be available? We upgraded the library due to security policy, and now the function is broken. Thanks, Coco Dai
v5.2.5 should be released in a few weeks. It would be helpful if you tried testing using a snapshot version of POI. They can be found here - https://ci-builds.apache.org/job/POI/job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/dist/maven/ The change related to https://github.com/apache/poi/pull/541 does not revert to the v5.2.3 behaviour. It tries to improve the width calculations by not rounding one of the intermediate values.
Created attachment 39388 [details] File auto changed the column size with 5.2.5
The file generated with 5.2.5 still have column content be cut off a little bit.see attachment
Created attachment 39389 [details] result of 5.2.3, 5.2.4, 5.2.5
The content would still be cut off 1 char at J50, this looks not totally fixed for me.
(In reply to Coco Dai from comment #7) > The content would still be cut off 1 char at J50, this looks not totally > fixed for me. Yes, same for me, it's not totally fixed. Content is still cut off! Worked good in version 5.2.3.
Unfortunately autosizing often cannot be 100% accurate because of different font-installations, special characters, operating-systems, Excel vs. LibreOffice and other factors, so we likely cannot make it work always perfectly! Even when opening the same Excel file in Excel and LibreOffice, there is very often a difference in how wide columns are. We might consider a customizable "adjustment factor" which would allow users to adjust it to their given environment.
*** Bug 68245 has been marked as a duplicate of this bug. ***
See https://bz.apache.org/bugzilla/attachment.cgi?id=39602 in bug #68245 for a standalone project to compare results of the two versions. Things to note from this test-case: * LibreOffice shows the columns properly, only Excel shows columns as "too small", so not even the UIs agree on how to handle this :(