poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 51622] autoSizeColumn does not sizes text when we have leading space in the cell
Date Wed, 04 Nov 2015 03:28:53 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=51622

--- Comment #2 from Javen O'Neal <onealj@apache.org> ---
Created attachment 33253
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33253&action=edit
SheetUtil.java fix

This problem still exists in POI 3.13 and the latest 3.14 dev build. Cell width
computation is done in org.apache.poi.ss.util.SheetUtil, so this bug is common
to HSSF, XSSF, and SXSSF workbooks.

The problem is here[1]:
> private static double getCellWidth(int defaultCharWidth, int colspan,
>         CellStyle style, double width, AttributedString str) {
> ...
>     width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth)
+ style.getIndention());

Should be (bounds.getX() + bounds.getWidth()), since the bounding box starts at
the first non-whitespace character.

This patch is untested and needs a corresponding unit tests before it can be
committed.

[1]
https://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java?view=markup#l180

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message