fastexcel icon indicating copy to clipboard operation
fastexcel copied to clipboard

autoSize column width doesn't account for fontSize

Open rodney757 opened this issue 6 years ago • 9 comments

If I set the cell style fontSize to say (14), the autoSizing that happens will not take into account the font size, and the cell will be partially hidden.

rodney757 avatar Sep 11 '18 23:09 rodney757

Fixed by PR #34.

ochedru avatar Sep 13 '18 22:09 ochedru

Thanks, for merging my PR's...

PR #34 doesn't fix this issue.

It does allow column width to be set manually, but it would be nice if the auto-width algorithm took into account the font size which it currently doesn't.

rodney757 avatar Sep 13 '18 22:09 rodney757

My bad. We'll have indeed to dig into auto sizing issues.

ochedru avatar Sep 14 '18 07:09 ochedru

I suppose this line needs some tweaking: https://github.com/dhatim/fastexcel/blob/ee98567d289f4e5d12a9506f757ed2fc367c53c6/fastexcel-writer/src/main/java/org/dhatim/fastexcel/Worksheet.java#L431

@ochedru What does this formula actually do? Why exactly those numbers (7,10,256)?

rzymek avatar Jul 26 '19 22:07 rzymek

This may be of some assistance: https://github.com/apache/poi/blob/9f07780bac1b86bd65be33857fc33d7fa50f0072/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java#L553

Looks fairly complex in Apache POI...

rzymek avatar Jul 26 '19 22:07 rzymek

As far as I can remember, I used a simplified version of what Apache POI does... My primary goal was to have something "good enough" with the default font, but time proves it was probably not that good 😄

ochedru avatar Jul 28 '19 21:07 ochedru

Is there any update for auto maximum column width for excel, As i sees based on text length and text font this size going to vary, if we use column.width() it will overrides the last value.

vSrkth avatar Apr 21 '21 05:04 vSrkth

+1 Having this would be really nice.

patric-r avatar Oct 27 '21 11:10 patric-r

+1, same issue here, when I change font size for 14, some column are partially hidden

EwaTrzemzalska avatar Jun 29 '22 11:06 EwaTrzemzalska