Closed RMOREANOV closed 2 months ago
The autofit method in the Worksheet struct incorrectly identifies autofilter header cells, causing improper adjustment of column widths.
I don't think that is the case. In the first example the column is autofitted correctly to the text width.
Also, the additional 16 pixel allowance for header cells is to prevent the dropdown arrow from obscuring the fitted text, like this:
I'm guessing that the "expected behaviour" example is an example of Excel's autofit. One thing to note about that is that the autofit width is the same regardless of whether the autofilter is on or off. The difference between the rust_xlsxwriter
and Excel output is explained in Notes on the XlsxWriter implementation of autofit(). Particularly in the section on "Fidelity with Excel".
The bug report mentions "dates" a few times but the example doesn't show any. In order to save time I'll point out that dates aren't currently handled properly since they have a separate number format that dictates the width of the cell. From the limitations section in the docs on autofit()
it says:
It doesn’t take number or date formatting into account, although it may try to in a later version.
That is still the case.
Closing as won't/can't fix.
Current behavior
The autofit method in the Worksheet struct incorrectly identifies autofilter header cells, causing improper adjustment of column widths. When autofilter is applied and date headers are added, the method does not consider the additional width occupied by these headers.
Expected behavior
The autofit method should accurately identify autofilter header cells, including the additional width occupied by date headers, and adjust the column width accordingly.
Sample code to reproduce
Environment
Any other information
In the autofit function (pub fn autofit(&mut self) -> &mut Worksheet {...}) of the Worksheet struct (worksheet.rs), the condition for identifying autofilter header cells is incorrect. It currently uses the row_num variable instead of the first_row property of the Worksheet dimensions. This causes the method to improperly adjust column widths.