D
David Thielen
Hi;
I am trying to convert from the XLSX col width to twips and back. I am using
the example from the Open XML spec. To go from the width to twips I am using:
float width = ((((((float) elem.getCol(colOn).getWidth() / 1440f) * 96f) /
7f) * 256f) - (int) (128f/7f)) / 256f;
Where getWidth() is the value from the XLSX file and 7 is the pixel width of
the default font.
For a column width of 15.123 the above gives me 1672 twips. But a screenshot
of the spreadsheet is 108 pixels wide. At 96 dpi that's 1620 twips. So
there's a difference of 52 twips.
And then to go from twips to width I do the inverse:
float width = ((((((float) elem.getCol(colOn).getWidth() / 1440f) * 96f) /
7f) * 256f) - (int) (128f/7f)) / 256f;
But that gets me 15.853 which is a bit different from the original 15.123.
What am I getting wrong on this?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
I am trying to convert from the XLSX col width to twips and back. I am using
the example from the Open XML spec. To go from the width to twips I am using:
float width = ((((((float) elem.getCol(colOn).getWidth() / 1440f) * 96f) /
7f) * 256f) - (int) (128f/7f)) / 256f;
Where getWidth() is the value from the XLSX file and 7 is the pixel width of
the default font.
For a column width of 15.123 the above gives me 1672 twips. But a screenshot
of the spreadsheet is 108 pixels wide. At 96 dpi that's 1620 twips. So
there's a difference of 52 twips.
And then to go from twips to width I do the inverse:
float width = ((((((float) elem.getCol(colOn).getWidth() / 1440f) * 96f) /
7f) * 256f) - (int) (128f/7f)) / 256f;
But that gets me 15.853 which is a bit different from the original 15.123.
What am I getting wrong on this?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm