Aggiorna e calcola la tabella pivot con elementi calcolati
Aggiornare e calcolare la tabella pivot con elementi calcolati
Il seguente esempio di codice carica il file Excel di origine che contiene una tabella pivot con tre elementi calcolati come “add”, “div”, “div2”. Innanzitutto, cambiamo il valore della cella D2 in 20, quindi aggiorniamo e calcoliamo la tabella pivot usando le API di Aspose.Cells for Node.js via C++ e salviamo il file in formato PDF. I risultati nel PDF di output mostrano che Aspose.Cells for Node.js via C++ ha aggiornato e calcolato con successo la tabella pivot con elementi calcolati. Puoi verificarlo utilizzando Microsoft Excel inserendo manualmente il valore 20 in D2 e aggiornando la tabella pivot tramite il tasto di scelta rapida Alt+F5 o cliccando sul pulsante Aggiorna nella tabella pivot.
const AsposeCells = require("aspose.cells.node"); | |
//For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
//The path to the documents directory. | |
var dataDir = RunExamples.GetDataDir("."); | |
//Load source excel file containing a pivot table having calculated items | |
var wb = new AsposeCells.Workbook(dataDir + "sample.xlsx"); | |
//Access first worksheet | |
var 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 | |
sheet.refreshPivotTables(); | |
//Save the workbook in output pdf | |
wb.save(dataDir + "RefreshAndCalculateItems_out.pdf", AsposeCells.SaveFormat.Pdf); |