You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Jochen Welle <jo...@fit.fraunhofer.de> on 2005/10/21 12:18:57 UTC

unit of sheet.getColumnWidth()

Hi,

I have a problem regarding the column width. I want to calculate the 
width in pixel from sheet.getColumnWidth(colNr). The problem I 
encountered is, that the value returned by getColumnWidth seems to be in 
units of a character width if the width equals getDefaultColumnWidth and 
otherwise it is in units of 1/256th of a character width (as said in the 
documentation).
Why does the unit change dependent on the value? Or am I doing something 
wrong?

I am using poi-2.5.1-final-20040804.jar.

I have a workaround for the behaviour (see below), but i think it is a bug.
Here is a code sample with my workaround:
private int getWidth(short colNr, HSSFSheet sheet)
{
   width = sheet.getColumnWidth(colNr) * 8;
   if (width != sheet.getDefaultColumnWidth())
       width /= 256;
   return width;
}

regards
Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/