poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 45805] Error in methode sheet.getColumnWidth(0)
Date Tue, 16 Sep 2008 22:08:03 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=45805


Josh Micich <josh@gildedtree.com> changed:

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




--- Comment #1 from Josh Micich <josh@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


Mime
View raw message