We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Bug in the computation of shape Height and Top properties

XlsIO is report the wrong height for a shape when the shape lies over a hidden row.

XlsIO assembly: 4.4.401.50

How to reproduce:

1. Create a chart and arrange that it lies over, say, 4 columns and 10 rows. It doesn't have to line up with column/row edges. Create a second chart and arrange for it to be directly below (but not overlapping) the first chart.

2. Measure the dimensions of both charts(for example by using a Paint tool) and make a note of their top and left positions as well.

3. In code grab the shape from both IChart objects (IShape shape = chart as IShape) and confirm that the IShape.Top, IShape.Left, IShape.Height and IShape.Width match the measurements taken using the graphics tool.

4. Now hide one of the columns and one of the rows that are covered by the first (uppermost) chart. The column/row selected should not be only partially covered by the chart.

5. Now repeat step 3. to obtain the dimensions of the chart once again.

While the chart has visibly changed size of height for the first (uppermost) chart reported by XlsIO is unchanged while the width has changed by the width of the hidden column.

The value of the Top property of the second (lower) chart has not changed while it should have decreased by the height of the hidden row.

Of course you might argue that these are the values they are supposed to have. However there are two arguements against this position. The first is that columns behave correctly. The width of the chart is changed by the width of the hidden column and the left position of any charts place to the right are adjusted as you'd expect. The second is that VBA code reporting on the dimensions of the shapes agrees with the column and disagrees with the row dimensions of the chart after hiding rows and columns.

Part of the explanation maybe the IWorksheet.GetRowHeightInPixels() value of a hidden row is reported to have a non-zero value whereas a hidden column reports a IWorksheet.GetColumnWidthInPixels() of zero. I believe that the mechanism underlying the erroneous reporting of a non-zero row height value for hidden rows is affecting the calculation of the image height.

Bill Seddon

2 Replies

BS Bill Seddon December 13, 2006 07:31 PM UTC

I think that the solution to this problem is to change line 191 of RowRecord.cs from:

return m_usHeigth;

to:

return (m_bZeroHeight ? (ushort)0 : m_usHeigth);

This has the effect of returning a height of zero if the row record indicates that the row should have no height but does so in a way that does not destroy the height of the row in case the row is restored.

With this fix in place, the ShapeImpl.GetHeight() method returns a correct height for shapes.


MW Melba Winshia Syncfusion Team December 14, 2006 09:06 AM UTC

Hi Bill,

Thank you for your valuable suggestion. I will forward this to the development team. Please let me know if you have any other questions.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon