Edit chart data in Slides

This thread is continuation of following thread:


This Topic is created by mudassir.fayyaz using the Email to Topic plugin.

HI,

We have worked with your sample code using Aspose.Slides for .NET 17.6 and Aspose.Cells for .NET 17.6 on our end and suggest you to please try using following modified code to serve the purpose.

public static void UpdateChartWorkbook()
{
    String path = "C:\\Aspose Data\\";

    Presentation pres = new Presentation(path + "SlideWithChart.pptx");
    foreach (var presSlide in pres.Slides)
    {
        foreach (var presSlideShape in presSlide.Shapes)
        {
            var chart = presSlideShape as Aspose.Slides.Charts.Chart;

            if (chart != null)
            {
                Workbook workbook;

                using (System.IO.MemoryStream msln = chart.ChartData.ReadWorkbookStream())
                {
                    workbook = new Aspose.Cells.Workbook(msln);

                    for (int r = 0; r <= workbook.Worksheets[0].Cells.MaxDataRow; r++)
                    {
                        for (int c = 0; c <= workbook.Worksheets[0].Cells.MaxDataColumn; c++)
                        {
                            var myValue = workbook.Worksheets[0].Cells[r, c].Value.ToString();
                            if (workbook.Worksheets[0].Cells[r, c].Value.ToString() == "#DB1.1A")
                            {
                                workbook.Worksheets[0].Cells[r, c].PutValue("Tyrone");
                            }
                        }

                    }

                }
                //workbook.Save(path + "SaveChart.xlsx");
                MemoryStream mem = new System.IO.MemoryStream();
               // mem = workbook.SaveToStream();
                workbook.Save(mem, Aspose.Cells.SaveFormat.Xlsx);
                mem.Position = 0;
             
                FileStream fs = new FileStream(path+"Aspose.Cells.xlsx", FileMode.OpenOrCreate);
                mem.WriteTo(fs);
                fs.Dispose();

                chart.ChartData.ChartDataWorkbook.Clear(0);
                chart.ChartData.WriteWorkbookStream(mem);

            }
        }
    }
    pres .Save(path + "SlideWithChart2.pptx",Aspose.Slides.Export.SaveFormat.Pptx);
}

Many Thanks,

Mudassir Fayyaz

The issues you have found earlier (filed as SLIDESNET-39016) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz