Rob Smeets
unread,Nov 2, 2009, 10:00:54 AM11/2/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spreadsheet::WriteExcel, jmcnamara
Dear John,
I've installed the new version 2.25.07, coming from 2.25. The problem
is still there, but smaller.
The excel sheet I'm working on contains 2 unscaled png files, that are
PHP-generated charts (bar and pie) with some text in the same font as
the text in the excel file itself. Because of this text and the lines
in the charts the small differences in graph size create easily
visible differences.
In the previous WriteExcel version both where about 1 pixel off. Now
only one is wrong.
It is a 630x200 png file that ends up in Excel as 5,32 x 16,67 cm,
while the original size is stated as 5,29 x 16,67. Since the chart
contains text it is immediately visible that there is something wrong
because the font looks somewhat vague, compared to some nearby text in
the excel sheet that actually has the same font.
The other chart is 630x380 pixels, and it ends up correctly in the
excel sheet.
Maybe the details help in hunting down the cause of this problem.
They are included thusly:
$worksheet->insert_image($lastheaderrow + 3, 0, $settings
{'CHART1filename'}, 3, 3, 1, 1) ;
$worksheet->insert_image($row, 0, $settings{'CHART2filename'}, 3, 3,
1, 1) ;
The first chart almost fills up a merged range of 4 columns and 18
rows. 1px borders all around this merged range. The top-border
actually belongs to the row above, left and bottom borders are
attached to the merged range itself, right border is actually the left
border of the cells to the right.
The second chart almost fills the height of its row, and extends over
almost 4 columns, no merging. It has a top-border but that is the
bottom-border of the row above.
I've included all this stuff on borders, because when I started
reading your source code, I noticed that you have to transform the
positioning settings of WriteExcel into a different set of parameters.
A fine occasion for some off-by-one errors. So I've created a second
version of my excel script that doesn't make any borders: problem
remains.
I've merged the cells that the second chart covers: problem still
exists.
I've extended the height of the row in which the second graph is
included: problem vanishes. The chart is 200 pixels high, shifted
(3,3), and the height of the row is calculated by my script as:
int($settings{'CHART2height'} / 1.3333) + 5 ;
I've varied the height of the row:
int($settings{'CHART2height'} / 1.3333) + 1 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 2 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 3 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 4 ; => ERROR: chart is
displayed 1 pixel too high
int($settings{'CHART2height'} / 1.3333) + 5 ; => ERROR: chart is
displayed 1 pixel too high
int($settings{'CHART2height'} / 1.3333) + 6 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 7 ; => ERROR: chart is
displayed 1 pixel too high
int($settings{'CHART2height'} / 1.3333) + 8 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 9 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 10 ; => FINE
int($settings{'CHART2height'} / 1.3333) + 11 ; => ERROR: chart is
displayed 1 pixel too high
int($settings{'CHART2height'} / 1.3333) + 12 ; => FINE
Hmm: no repetition mod 3 or 4 (related to the 4/3 ratio between pixels
and excel-units).
Removing the border on the row above the chart does not seem to change
these results, it just enlarges the margin above the chart by 1 pixel.
I've looked at the "+6"-test in more detail by examing a screenshot
with Paint: excel says the row height is 156,00 (208 pixels), but it
contains the 200px chart, 3px margin above the chart en 6px below,
making 209 in total (the light grey cell borders are off by default in
this chart).
The "+4"-test: excel says rowheight=153,75 EU=205px. Paint says 206px.
So that is the same 1px difference as in the "+6"-test. However in one
case the graph-height is stretched by 1px and in the other it is not.
I hope this helps.
/Rob Smeets