Yenileme ve Hesaplanmış Öğeleri Olan Özet Tabloyu Yenileme
Hesaplanmış öğeleri olan özet tabloyu yenileme ve hesaplama
Aşağıdaki örnek kod, ‘add’, ‘div’, ‘div2’ gibi üç hesaplanmış öğesi olan bir özet tabloyu içeren kaynak excel dosyasını yükler. Önce D2 hücresinin değerini 20 olarak değiştirir ve ardından Aspose.Cells için Python via .NET API’leri kullanarak özet tabloyu yeniler ve hesaplar, ve çalışma kitabını PDF formatında kaydeder. Sonuçlar çıktı PDF’inde gösterilmektedir. Aspose.Cells için Python via .NET’nin hesaplanmış öğeleri olan özet tabloyu başarıyla yenilediğini ve hesapladığını kontrol etmek için manuel olarak D2 hücresine 20 değerini yerleştirerek ve ardından alt+F5 kısayol tuşu ile veya özet tabloyu tıklatarak yenileyebilirsiniz.
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Load source excel file containing a pivot table having calculated items | |
wb = Workbook(dataDir + "sample.xlsx") | |
# Access first worksheet | |
sheet = wb.worksheets[0] | |
# Change the value of cell D2 | |
sheet.cells.get("D2").put_value(20) | |
# Refresh and calculate all the pivot tables inside this sheet | |
for pt in sheet.pivot_tables: | |
pt.refresh_data() | |
pt.calculate_data() | |
# Save the workbook in output pdf | |
wb.save(dataDir + "RefreshAndCalculateItems_out.pdf", SaveFormat.PDF) |