You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2007/10/31 15:51:41 UTC

DO NOT REPLY [Bug 43751] New: - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751

           Summary: The HSSFSheet.autoSizeColumn method doesn't handle
                    rotated text well and truncates long decimal values
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: kanobe@gmail.com


The HSSFSheet.autoSizeColumn method doesn't handle rotated text well. When a
text value is entered into a column cell and the cell style is set to rotate the
text 90 degrees, the width of the generated cell is still sized to the unrotated
width of the text string. 

Additionally, the HSSFSheet.autoSizeColumn method doesn't handle numeric values
with more than 3 fractional decimal digits properly (for example the value
3.45334). For such values the generated cell is too narrow. It seems that for
Excel numeric values using the General format the method formats the number
using a java DecimalFormat object with the default constructor, which seems to
default to a pattern that only outputs three fractional digits (so 3.45334 would
be output as 3.453).

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751





------- Additional Comments From kanobe@gmail.com  2007-10-31 08:02 -------
Created an attachment (id=21067)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21067&action=view)
Proposed fix to solve the two issues in the bug report

Here is an updated version of HSSFSheet.java (org.apache.poi.hssf.usermodel)
that fixes the two issues. If you would like a patch instead, let me know. 

The implemented fix solves the rotated text problem by performing some
transformations on the text before determining it's width:

1. First, the text is scaled vertically by a multiple of the font "leading"
value so that text rotated close to 90 degrees will have some whitespace around
it in the final output

2. Second, the text is rotated by the rotation specified in the cell layout

After these transformations the new width is determined from the text bounding
box.

The fix solves the numerical value problem by no longer using DecimalFormat to
format numerical cells that have the Excel "General" format, but instead using
a simple string conversion.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751





------- Additional Comments From kanobe@gmail.com  2007-10-31 07:53 -------
Created an attachment (id=21066)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21066&action=view)
Java program that demonstrates the issues

This is a Java program that demonstrates the issues described in the bug
report. It outputs a series of cells in a single row, text then numbers, each
rotated. The output file is named 'rotated_columns.xls'.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751


yegor@dinom.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From yegor@dinom.ru  2007-11-03 12:39 -------
patch applied.

Thanks,
Yegor

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751





------- Additional Comments From kanobe@gmail.com  2007-10-31 08:04 -------
Created an attachment (id=21068)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21068&action=view)
autoSizeColumn before fix

This is the output of the AutosizeRotatedTextColumns program BEFORE the
proposed fix.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751





------- Additional Comments From yegor@dinom.ru  2007-11-01 04:24 -------
Very cool. Thanks for the patch.
I wrote autoSizeColumn without text rotation in mind but your fix extends it in
a very elegant way. 

Yegor

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 43751] - The HSSFSheet.autoSizeColumn method doesn't handle rotated text well and truncates long decimal values

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43751





------- Additional Comments From kanobe@gmail.com  2007-10-31 08:05 -------
Created an attachment (id=21069)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21069&action=view)
Sample output after implementing the fix

This is the output of the AutosizeRotatedTextColumns program AFTER the proposed
fix.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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