We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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);
	w.Save(@"New.xls");
}

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].Charts.Clear();
    pAsposeWorkbook.Worksheets[0].Pictures.Add(0, 0, sPictureStream);

    return true;
}

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

@Bharat_Chovatiya,

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

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

@bharat_Chovatiya
Please try the latest release version 23.1

Hi Simon,

Yes, the issue is resolved.

Thanks

Bharat

@Bharat_Chovatiya,

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