Read and Manipulate Excel 2016 Charts
Possible Usage Scenarios
Aspose.Cells now supports the reading and manipulation of Microsoft Excel 2016 charts which are not present in Microsoft Excel 2013 or earlier versions.
Read and Manipulate Excel 2016 Charts
The following sample code loads the source excel file which contains Excel 2016 charts in the first worksheet. It reads all charts one by one and changes its title as per its chart type. The following screenshot shows the source excel file before the execution of code. As you can see, chart title is same for all charts.
The following screenshot shows the output excel file after the execution of code. As you can see, the chart title is changed as per its chart type.
Sample Code
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Load source excel file containing excel 2016 charts | |
Workbook book = new Workbook(dataDir + "excel2016Charts.xlsx"); | |
// Access the first worksheet which contains the charts | |
Worksheet sheet = book.Worksheets[0]; | |
// Access all charts one by one and read their types | |
for (int i = 0; i < sheet.Charts.Count; i++) | |
{ | |
// Access the chart | |
Chart ch = sheet.Charts[i]; | |
// Print chart type | |
Console.WriteLine(ch.Type); | |
// Change the title of the charts as per their types | |
ch.Title.Text = "Chart Type is " + ch.Type.ToString(); | |
} | |
// Save the workbook | |
book.Save(dataDir + "out_excel2016Charts.xlsx"); |
Console Output
Here is the console output of the above sample code when executed with the provided source excel file.
Waterfall
Treemap
Sunburst
Histogram
BoxWhisker