Free Support Forum - aspose.com

How to get the image of the chart in a separate sheet?

I have attached the excel file namely sourceChart.xls, it has two sheets namely Chart1 and Sheet1, I want to take the image of the sheet Chart1 which is basically an excel chart. Is it possible? Please provide me code example as soon as possible.

Hi,

Please check the following code for your need:

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
workbook.Open(@"d:\test\sourceChart.xls");
Aspose.Cells.Chart chart = workbook.Worksheets["Chart1"].Charts[0];
Bitmap bitmap = chart.ToImage();
bitmap.Save(@"d:\test\ChartImage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

Thank you.