Läs och manipulera Excel 2016-diagram
Contents
[
Hide
]
Möjliga användningsscenarier
Aspose.Cells stöder nu läsning och manipulering av Microsoft Excel 2016-diagram som inte finns i Microsoft Excel 2013 eller tidigare versioner.
Läs och manipulera Excel 2016-diagram
Följande exempelkod laddarsource excel-filsom innehåller Excel 2016-diagram i det första kalkylbladet. Den läser alla diagram en efter en och ändrar sin titel enligt dess diagramtyp. Följande skärmdump visar källexcelfilen innan koden körs. Som du kan se är diagramtiteln densamma för alla diagram.
Följande skärmdump visaroutput excel-fil efter exekvering av kod. Som du kan se ändras diagramtiteln enligt dess diagramtyp.
Exempelkod
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"); |
Konsolutgång
Här är konsolutgången för ovanstående exempelkod när den körs med den medföljandesource excel-fil.
Waterfall
Treemap
Sunburst
Histogram
BoxWhisker