Hesaplanan Öğelere Sahip Pivot Tabloyu Yenileyin ve Hesaplayın
Contents
[
Hide
]
Aspose.Cells artık hesaplanan öğelere sahip pivot tablonun yenilenmesini ve hesaplanmasını destekliyor. Lütfen kullanPivotTable.refreshData() vePivotTable.caclulateData() bu işlevi gerçekleştirmek için her zamanki gibi.
Hesaplanan Öğelere Sahip Pivot Tabloyu Yenileyin ve Hesaplayın
Aşağıdaki örnek kod,kaynak excel dosyası“add”, “div”, “div2” gibi hesaplanan üç öğeye sahip bir pivot tablo içerir. Önce D2 hücresinin değerini 20 olarak değiştiriyoruz ve ardından Aspose.Cells API’leri kullanarak pivot tabloyu yenileyip hesaplıyor ve çalışma kitabını PDF formatında kaydediyoruz. Sonuçlarçıkış PDF Aspose.Cells’in öğeleri başarıyla hesaplayarak pivot tabloyu yenilediğini ve hesapladığını gösterir. Microsoft Excel kullanarak, D2 hücresine 20 değerini manuel olarak koyarak ve ardından Alt+F5 kısayol tuşuyla veya pivot tablo Yenile düğmesine tıklayarak pivot tabloyu yenileyerek doğrulayabilirsiniz.
This file contains hidden or 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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RefreshCalculatePivotTablehavingCalculatedItems.class); | |
// Load source excel file containing a pivot table having calculated | |
// items | |
Workbook wb = new Workbook(dataDir + "sample.xlsx"); | |
// Access first worksheet | |
Worksheet sheet = wb.getWorksheets().get(0); | |
// Change the value of cell D2 | |
sheet.getCells().get("D2").putValue(20); | |
// Refresh and calculate all the pivot tables inside this sheet | |
for (int i = 0; i < sheet.getPivotTables().getCount(); i++) { | |
PivotTable pt = sheet.getPivotTables().get(i); | |
pt.refreshData(); | |
pt.calculateData(); | |
} | |
// Save the workbook in output pdf | |
wb.save(dataDir + "output.pdf", SaveFormat.PDF); |