Free Support Forum - aspose.com

How to draw stacked bar

I would like to how I would be able to update the data in the chart provided in the pptx file uploaded.


the data that i would like to update the chart is in the Excel file NewData this data is added as it is is added to a datatabel, which works fine,

I have a method that put the data into the form of the second excel file, newdata2, as can be seeen all of the heading also move around so they need to be written in.

I would like to know i would be able to write the second excel data into the chart a display the chart using the datatable


this is all done is asp.net

Hi Kartik,


I have observed the query shared by you and have been able to devise the solution for you. I like to share that since you are using a separate excel file to use as data table, you need to involve Aspose.Cells as well in this regard to get things going on. Please use the following sample code to serve the purpose.

public static void ChangeChartTable()
{
String path = @“D:\Aspose Data”;
PresentationEx pres = new PresentationEx(path + “Presentation2_Sample.pptx”);

SlideEx slide = pres.Slides[0];
ChartEx chart = (ChartEx)slide.Shapes[0];

ChartDataEx chData = chart.ChartData;
//Logic for merging category labels

Workbook wb = new Workbook(path+“NewData2.xlsx”);

MemoryStream ms = new MemoryStream();
wb.Save(ms, SaveFormat.Auto);
ms.Position = 0;

chart.ChartData.WriteWorkbookStream(ms);

pres.Write(@“D:\Aspose Data\Presentation2_Sample_Modified.pptx”);
}


For your kind reference, I have attached the generated presentation as well. There is a minor issue here that although the chart data will get changed but when you will first open the chart for the first time in PowerPoint you will see the chart with old values. You will have to just open the chart in edit data mode and then save that back and you will see that values will get reflected automatically. I have also created an issue with ID SLIDESNET-33979 to further investigate and resolve the issue. Meanwhile, you may please use the work around method specified by me.

Please share, if I may help you further in this regard.

Many Thanks,

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.