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 2008/09/15 13:30:49 UTC
DO NOT REPLY [Bug 45805] New: Error in methode
sheet.getColumnWidth(0)
https://issues.apache.org/bugzilla/show_bug.cgi?id=45805
Summary: Error in methode sheet.getColumnWidth(0)
Product: POI
Version: 3.0-dev
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: thorstenbux@gmx.de
Created an attachment (id=22564)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=22564)
sheet.getColumnWidth(0) returns negative value
On Mon, 15 Sep 2008, Thorsten Bux wrote:
> i tried to get the width of a column with the sheet.getColumnWidth(0)
> method. If the column width in excel is bigger than a specific size (i
> think bigger 127 / 890px) then the method sheet.getColumnWidht(0)
> returns a negative value.
Probably a unsigned 16 bit vs signed 16 bit issue. Probably best if you
create a new bug on bugzilla, and upload a simple test case that shows it
up.
Nick
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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
DO NOT REPLY [Bug 45805] Error in methode sheet.getColumnWidth(0)
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45805
Josh Micich <jo...@gildedtree.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Josh Micich <jo...@gildedtree.com> 2008-09-16 15:08:02 PST ---
Pretty easy to reproduce this bug:
sheet.setColumnWidth((short)0, (short)40000);
assertEquals((short)40000, sheet.getColumnWidth((short)0));
Excel column widths are 16 bit unsigned values, but POI was using java shorts
for that purpose. To fix this bug (svn r696075 / r696084), several methods
with this problem have been deprecated and replaced with versions that use
ints.
There is a work-around to java's lack of 16-bit unsigned shorts. Simply
convert (signed) shorts to ints by ANDing with 2^^16-1. For example:
int width = sheet.getColumnWidth((short)0) & 0xFFFF;
However, once you have this bug-fix, the same code can be written:
int width = sheet.getColumnWidth(0);
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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