Чтение и обработка диаграмм Excel 2016
Contents
[
Hide
]
Возможные сценарии использования
Aspose.Cells теперь поддерживает чтение и обработку Microsoft диаграмм Excel 2016, которых нет в Microsoft Excel 2013 или более ранних версиях.
Чтение и обработка диаграмм Excel 2016
Следующий пример кода загружаетисходный файл excelкоторый содержит диаграммы Excel 2016 на первом листе. Он читает все диаграммы одну за другой и меняет название в соответствии с типом диаграммы. На следующем снимке экрана показан исходный файл Excel перед выполнением кода. Как видите, название диаграммы одинаково для всех диаграмм.
На следующем снимке экрана показановыходной файл excel после выполнения кода. Как видите, заголовок диаграммы меняется в соответствии с типом диаграммы.
Образец кода
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
Консольный вывод
Вот вывод консоли приведенного выше примера кода при выполнении с предоставленнымисходный файл excel.
Waterfall
Treemap
Sunburst
Histogram
BoxWhisker