Hello,
I have a PPT presentation with an embedded graph from Excel. When programatically modifying the cells that the chart is based on add then saving it as different presentation, the new presentation looks exactly the same. I am using the trail version of Aspose Total for .Net. Below is the code that I’m using:
private void generateDRGChangeGraph(Presentation ppt)
{
ISlide slide = ppt.Slides[0];
OleObjectFrame oleObjectFrame = null;
// Traversing all shapes for oleObjectFrame frame
foreach (IShape shape in slide.Shapes)
{
if (shape is OleObjectFrame)
{
oleObjectFrame = (OleObjectFrame)shape;
}
}
if (oleObjectFrame != null)
{
// Reading object data in Workbook
Aspose.Cells.Workbook Wb;
using (System.IO.MemoryStream msln = new System.IO.MemoryStream(oleObjectFrame.ObjectData))
{
Wb = new Aspose.Cells.Workbook(msln);
using (System.IO.MemoryStream msout = new System.IO.MemoryStream())
{
// Modifying the workbook data
Wb.Worksheets[7].Cells[5, 2].PutValue(1);
Wb.Worksheets[7].Cells[6, 2].PutValue(0.5);
Wb.Worksheets[7].Cells[7, 2].PutValue(0.25);
Wb.Worksheets[7].Cells[8, 2].PutValue(0.75);
Aspose.Cells.OoxmlSaveOptions so1 = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);
Wb.Save(msout, so1);
// Changing Ole frame object data
msout.Position = 0;
oleObjectFrame.ObjectData = msout.ToArray();
}
}
}
// Write the presentation as a PPTX file
ppt.Save(@"…\Reporting\ReportingTemplates\OleEdit_out.pptx", SaveFormat.Pptx);
}