We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Binding XML Data

I am trying to build some charts that will ultimately go in a DOC and PPT file. I first started looking at the Aspose.Report.Chart class as that appears to be the preferred way. The Chart class has a “BindXML” method that takes an XML formatted string and binds it to a Chart object, creating data series, modifying properties, etc. This method works pretty well for what I want. However, I have noticed that the charts produced by Aspose.Report (in certain cases) aren’t as attractive as similar charts produced via the Chart class in Aspose.Cells. There are some subtle details that don’t appear to be reproducible using the Aspose.Reports.Chart API. So, I thought I might give the charts in Aspose.Cells a try.

I can create an Aspose.Cells.Chart chart, populate it with some data, extract the image, and insert the image into the Aspose.Words doc just fine programmatically. My main question is:

Is there any similar “BindXML” functionality for Aspose.Cells?

I don’t see anything in the API, but perhaps there is a related class that I’m just missing. I found this related thread from a while back:
Directly populating XML data into Excel

A secondary question is, what is the reason that the Aspose family of technologies has these 2 seemingly separate and distinct chart classes/APIs? It seems like it would be better to have a unified, consistent API to charting in the Aspose family.


Well, Aspose.Cells for .NET provides Chart APIs to create/manipulate native excel charts. You can create chart in MS Excel format (Xls/Xlsx), you may open the excel file into MS Excel and can check the chart would be saved as chart object and not static pictures, so you may edit in MS Excel if you want. Regarding Aspose.Report.Chart component, it provides the api to create sophisticated charts, the charts would be a mere static picture that you may get. So, if you need to create/manipulate native excel charts(you may also get the picture of the chart using Aspose.Cells.Chart.ToImage() API), you may use Aspose.Cells component. If you need sophisticated or non native excel charts, you may use Aspose.Report.Chart product for your need. Regarding consistency for the Chart APIs in both components, well, since both provide diverse charts, so the apis cannot be the same and cannot be unified either.

Regarding BindXML functionality, I think you may read an xml file to fill a datatable/dataset using ADO.NET APIs and then import the datatable to the worksheet using Aspose.Cells APIs. Later on you may create the chart using Aspose.Cells’s Chart APIs. e.g

DataSet ds = new DataSet();
FileStream fs = new FileStream(“d:\test\xdata.xml”,FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create your chart using the apis.

Thank you.