Applicare il subtotale e cambiare direzione delle righe di riepilogo dell outline sotto il dettaglio

Immagini dei file di origine e di output

La seguente immagine mostra il file Excel di origine utilizzato nel codice di esempio sottostante che contiene alcuni dati nelle colonne A e B.

todo:image_alt_text

La seguente schermata mostra il file Excel generato dal codice di esempio. Come si può vedere, è stato applicato un subtotale al range A2:B11 e la direzione dell’outline è righe di riepilogo sotto i dettagli.

todo:image_alt_text

Node.js per applicare subtotali e cambiare la direzione delle righe di riepilogo del contorno

Ecco il codice di esempio per ottenere l’output mostrato sopra.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
const AsposeCells = require("aspose.cells.node");
// Create workbook from source Excel file
var workbook = new AsposeCells.Workbook("Book1.xlsx");
// Access the first worksheet
var worksheet = workbook.getWorksheets().get(0);
// Get the Cells collection in the first worksheet
var cells = worksheet.getCells();
// Create a cellarea i.e.., A2:B11
var ca = AsposeCells.CellArea.createCellArea("A2", "B11");
// Apply subtotal, the consolidation function is Sum and it will applied to Second column (B) in the list
cells.subtotal(ca, 0, AsposeCells.ConsolidationFunction.Sum, [1], true, false, true);
// Set the direction of outline summary
worksheet.getOutline().setSummaryRowBelow(true);
// Save the excel file
workbook.save("output_out.xlsx");