Free Support Forum -

Slide Problem - Data Labels and second series

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);


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/";

this.Response.AppendHeader("Content-Disposition", "attachment; filename=Test.pptx");


System.IO.Stream st = this.Response.OutputStream;



Please let me know if I am missing something.

Hello Dear,

Thanks for your interest in Aspose.Slides.

I have worked with the presentation file shared by you and have been able to generate the correct presentation. I have used Aspose.Slides for .NET 5.1.0 for my investigation. Can you please try using the mentioned version. For your reference, I have also attached the generated presentation. Please share with us, if you still feel any issue.

Thanks and Regards,

I had the same issue, Aspose.Slides doesn’t support data labels. I ended up using Aspose.Cells to pull a chart from an existing excel file instead of using embedded powerpoint charts. So instead of having a single .pptx template I also have a .xlsx template just for the needed charts. For example (_workbook is a stream from an existing .xlsx file):

var worksheet = _workbook.Worksheets[“HCRParticipation”];

var charts = worksheet.Charts.OfType<Aspose.Cells.Charts.Chart>().ToList();
Aspose.Cells.Charts.Chart chart = charts.FirstOrDefault(x => x.Name == “Main”);
MemoryStream stream = new MemoryStream();
chart.ToImage(stream, new Aspose.Cells.Rendering.ImageOrPrintOptions()
HorizontalResolution = 300,
VerticalResolution = 300

ImageEx imgEx = slide.Parent.Images.AddImage(stream);
int frameID = slide.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, (float)(4.95 / 0.013888889), (float)(2.58 / 0.013888889), imgEx.Image.Width / 4.16f, imgEx.Image.Height / 4.16f, imgEx);

PictureFrameEx frame = (PictureFrameEx)slide.Shapes[frameID];

I’m not sure if you purchased aspose cells or not…

You are correct that it does generate a slide. But my problems still persist. In the slide that you attached showing it works properly still does not have the labels nor does it apply data the second series. Please re-read my original post and reply accordingly. I’m afraid I will have to head down the Excel hack path I have been seeing.

Hello Dear,

I have worked with the presentation file and code snippet in detail. Actually, in your code snippet you did not add new series and that is why it worked fine. I have been able to observe the issue while adding new series in the chart. An issue with ID 26522 has been created in our issue tracking system to further investigate and resolve the issue. Secondly, the support chart labels are not supported at the moment and an issue with ID 25212 has already been created in our issue tracking system to provide this feature.

Dear, I like to share that we are currently working on re-implementation of chart support by completely isolating it from Aspose.Cells for .NET and hopefully, many known and unknown issues will get resolved by then. We are expecting to accomplish this by end of Q2. As a work around, I may suggest you to use a chart template that already has multiple series in it and you tailor them to meet your needs.

We are sorry for your inconvenience,

The issues you have found earlier (filed as 26522) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.