Unable to add new data points in embedded excel chart in prsentation

Hi,


I am having an embedded excel chart(one worksheet contains chart and the other worksheet contains the chart data) in a presentation(pptx) template file. Using this as source file, I added new data points in the second worksheet. When I open the generated output presentation file, what I found is, newly added data points are NOT visible in the charts but they are present the second worksheet(that contains the chart data).

I’m using below code:
//loading source template
PresentationEx _source = new PresentationEx(@“D:\Input.pptx”);
PresentationEx _destination = new PresentationEx();

int index = _destination.Slides.AddClone(_source.Slides[11]);
SlideEx slide = _destination.Slides[index];
OleObjectFrameEx OLEobj = (OleObjectFrameEx)slide.Shapes.ToArray().Where(x => x.AlternativeText == “OLEObject”).FirstOrDefault();

if (OLEobj != null)
{
//Reading object data in Workbook
Aspose.Cells.Workbook Wb;

// open the Excel Chart inside the workbook
MemoryStream msIn = new MemoryStream(OLEobj.ObjectData);
Workbook wb = new Workbook(msIn);

// set some data
int MaxDataRowIndex = wb.Worksheets[1].Cells.MaxDataRow;
int MaxDataColumnIndex = wb.Worksheets[1].Cells.MaxDataColumn;

wb.Worksheets[1].Cells[MaxDataRowIndex, 0].PutValue(“2015 Wave 1”);
wb.Worksheets[1].Cells[MaxDataRowIndex, 1].PutValue(30);
wb.Worksheets[1].Cells[MaxDataRowIndex, 2].PutValue(30);
wb.Worksheets[1].Cells[MaxDataRowIndex, 3].PutValue(30);

// now save back the modified workbook to memory stream
MemoryStream msOut = wb.SaveToStream();
//Changing Ole frame object data
OLEobj.ObjectData = msOut.ToArray();

_destination.Save(@"D:\Output, Aspose.Slides.Export.SaveFormat.Pptx);

}

Please help me as soon as possible.

Regards,
Naveen

Hi Naveen.

Thanks for your interest in Aspose.Slides.

I have observed the sample code shared by you. You are probably having an excel chart embedded as Ole object in PowerPoint. Please remember here that any thing added as Ole object does not loose its actual format. Like and excel chart will remain on MS Excel end. So, you need to use Aspose.Cells Charting mechanism to add new category or series in the chart that you want to make part of chart. Filling the data point does not make the cells part of the chart unless you define that so. I request you to please consult Aspose.Cells forum in this regard to see how to work with charts.

Secondly, instead of adding chart as Ole object in Aspose.Slides, the better approach is to use the MSO chart support available in Aspose.Slides which gives similar charting support as available in Aspose.Cells MS Excel charts. Please visit this documentation section to see how to work with charts in Aspose.Slides.

Many Thanks,