Excel 2016 Grafiklerini Okuma ve Değiştirme
Olası Kullanım Senaryoları
Aspose.Cells artık Microsoft Excel 2016 grafiklerini okuma ve değiştirme desteği sunmaktadır, bu özellik Microsoft Excel 2013 veya daha önceki sürümlerde bulunmamaktadır.
Excel 2016 Grafiklerini Okuma ve Değiştirme
Aşağıdaki örnek kod, Excel 2016 grafiklerini içeren kaynak excel dosyasını yükler. Tüm grafikleri tek tek okur ve türüne göre başlığını değiştirir. Aşağıdaki ekran görüntüsü, kodun çalıştırılması öncesi kaynak excel dosyasını göstermektedir. Görebileceğiniz gibi, grafik başlığı tüm grafikler için aynıdır.
Aşağıdaki ekran görüntüsü, kodun çalıştırılması sonrası çıktı excel dosyasını göstermektedir. Görebileceğiniz gibi, grafik başlığı türüne göre değişmiştir.
Örnek Kod
// 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"); |
Konsol Çıktısı
Yukarıdaki örnek kodun kaynak excel dosyası ile çalıştırılması sonucu konsol çıktısı
Waterfall
Treemap
Sunburst
Histogram
BoxWhisker