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 45105] Column width not correctly mapped to xls file ( office 2003), while defaultColumnWidth is
Date Mon, 09 Jun 2008 09:11:33 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=45105


Yegor Kozlov <yegor@dinom.ru> changed:

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




--- Comment #1 from Yegor Kozlov <yegor@dinom.ru>  2008-06-09 02:11:33 PST ---
This is how Excel works.
The width of 1 pixel measured in Excel units (1/256th of a character) is
different for columns width default and modified width.

For columns with the default width 1px=32, so 2048/32=64px
For columns with modified width 1px=36.56  and 2048/36.56=56px 

The constant 36.56 was found empirically. The Excel spec says nothing about it. 

Here is a mock up of a method which returns column width in pixels. 

    public int getColumnWidthInPixels(HSSFSheet sheet, short column){

        float px_default = 32.00f;  //width of 1px in columns with the default
width
        float px_modified = 36.56f; //width of 1px in columns with modifed
width

        //column width in units of 1/256th of a character
        int cw = sheet.getColumnWidth(column);

        //default column width in units of 1/256th of a character
        int dw = sheet.getDefaultColumnWidth()*256;

        float px = cw/(cw == dw ? px_default : px_modified);

        return Math.round(px);
    }


Regards,
Yegor


-- 
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