Data loss in saving a pivot table chart

I am getting data loss when try to Convert a Pivot chart to image Excel file. The attachment includes Original.xls that I am trying to open, and save as New.xls after replacing a chart with an image created from the chart which is included as well. I am using Aspose.Cells 22.11

The sheet named “Sheet 1” has a chart which is becoming blank when the file is opened and saved without any change.

The following is the code I am using.

private void bStart_Click(object sender, EventArgs e)
	Aspose.Cells.Workbook w = new Aspose.Cells.Workbook(@"Original.xls");
	ReplaceChartSheetWithPicture(ref w);

private static bool ReplaceChartSheetWithPicture(ref Aspose.Cells.Workbook pAsposeWorkbook)
    Aspose.Cells.Rendering.ImageOrPrintOptions iOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();

    pAsposeWorkbook.Worksheets[0].Type = Aspose.Cells.SheetType.Worksheet;
    //Get chart picture
    MemoryStream sPictureStream = new MemoryStream();
    Aspose.Cells.Charts.Chart c = pAsposeWorkbook.Worksheets[0].Charts[0];
    Bitmap bImage = pAsposeWorkbook.Worksheets[0].Charts[0].ToImage(iOptions);
    bImage.Save(sPictureStream, System.Drawing.Imaging.ImageFormat.Png);
    pAsposeWorkbook.Worksheets[0].Pictures.Add(0, 0, sPictureStream);

    return true;

Please let me know how to create the chart successfully. (52.2 KB)


We will evaluate your issue using your template file and get back to you soon.

We have found your mentioned issues and logged it with issue id: CELLSNET-52438.

Please try the latest release version 23.1

Hi Simon,

Yes, the issue is resolved.




Thanks for your feedback and good to know that your issue is resolved in the new version.

The issues you have found earlier (filed as CELLSNET-52438) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi