Chart image ignores height and width setting

We are converting a portion of the excel(cell range or chart) to an image using aspose cells.
We found an issue related to setting height and width of the output image.
In the attached sample, if you set width and height for tabular data (when Excel Data Type: Tabular data is selected), it works fine. It crops the image as per the values specified in Desired Width and Desired Height text boxes.

But for Chart Data (when Excel Data Type: Chart data is selected), both height and width are ignored.

Note: I have removed aspose dll in the sample.
Please look into this issue and provide us a fix. (259.7 KB)



I have generated two images both with TabularData and ChartData. Could you please mention the height and width you want to generate image of, while sharing expected output created by MS Excel. We will then provide our feedback after analysis.
Tabular-Jpeg.Jpeg.png (37.2 KB)
Chart-Column-Jpeg.Jpeg.png (27.1 KB)

You have to set the width and height to other than 0px, in the respective Textboxes when you are running the application.

Then you can see the incorrect behaviour for chart type, tabular image works fine as i said before.


We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46641 - Chart image ignores height and width setting


We evaluated your issue further.
You should set the chart’s width or height by sourceChart.ChartObject.Width or Height in ConvertObjectToBytes() method of InvMetricsAsposeCells.cs. It’s best that you don’t change the size of chart directly. If you do so, the chart maybe changed too. You may serialize Emf formatted type image by imageOrPrintOptions.ImageType = ImageType.Emf. When render the Emf image to picture Box, you can set the picture box size properties to get expected size.