I am having a couple problems with Aspose Slides for .Net when manipulating a chart from a template I've opened. The chart (in the template) consists of two series. The first is a bar and second is a line. The data for the chart is being added programatically based on results from a query.
The first problem is that the data labels on the bar series are being droppped.
The second problem is that I cannot access the second series to add values. All the values are being updated properly in the underlying data set in the chart, but it is not picking up those new values for the second series without manual intervention after the slide deck is generated and opened. If I try to add a series, it creates a corrupt slide and PowerPoint will replace it with a blank slide.
Below is a slimmed down version of the code I'm using to generate the file. I've also attached both the template pptx and the one that is generated by the code.
SlideEx slide = null;
string path = System.Web.HttpContext.Current.Server.MapPath("~");
path += @"\ExcelTemplates\Test - Template.pptx";
System.IO.FileStream s = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
PresentationEx pres = new PresentationEx(s);
s.Close();
slide = pres.Slides[0];
ChartEx chart = (ChartEx)(slide.Shapes[2]);
Aspose.Cells.Workbook book = (Aspose.Cells.Workbook)(chart.ChartData.Workbook);
Aspose.Cells.Worksheet sheet = book.Worksheets[0];
sheet.Cells[1, 0].PutValue("October");
sheet.Cells[1, 1].PutValue(13.5);
sheet.Cells[1, 2].PutValue(24);
chart.ChartData.GetSeries(0).Values.Add(sheet.Cells[1, 1]);
//chart.ChartData.GetSeries(1).Values.Add(sheet.Cells[1, 2]); /*** Assigning to the second series causes a runtime error ******/
chart.ChartData.AddCategory(sheet.Cells[1, 0], sheet);
sheet.Cells[2, 0].PutValue("November");
sheet.Cells[2, 1].PutValue(6.5);
sheet.Cells[2, 2].PutValue(32);
chart.ChartData.GetSeries(0).Values.Add(sheet.Cells[2, 1]);
//chart.ChartData.GetSeries(1).Values.Add(sheet.Cells[2, 2]);
chart.ChartData.AddCategory(sheet.Cells[2, 0], sheet);
sheet.Cells[3, 0].PutValue("December");
sheet.Cells[3, 1].PutValue(8.3);
sheet.Cells[3, 2].PutValue(17);
chart.ChartData.GetSeries(0).Values.Add(sheet.Cells[3, 1]);
//chart.ChartData.GetSeries(1).Values.Add(sheet.Cells[3, 2]);
chart.ChartData.AddCategory(sheet.Cells[3, 0], sheet);
////Data labels on bar chart are lost
////Does not expand values used in chart data
this.Response.ContentType = "application/vnd.ms-powerpoint";
this.Response.AppendHeader("Content-Disposition", "attachment; filename=Test.pptx");
this.Response.Flush();
System.IO.Stream st = this.Response.OutputStream;
pres.Write(st);
this.Response.End();
Please let me know if I am missing something.