Tenho um script que cria uma tabela dinâmica, mas não quero exibir subtotais, apenas totais finais.
function main(workbook: ExcelScript.Workbook) {
let sheet = workbook.getActiveWorksheet(); // Downloading the active sheet
// Finding the range with the data (I assume it starts with A1)
let dataRange = sheet.getRange("A1").getSurroundingRegion();
// Checking that the scope is correct
if (!dataRange) {
console.log("No data found.");
return;
}
// Creating a pivot table on the same sheet
let pivotTable = sheet.addPivotTable("February", dataRange, sheet.getRange("H1"));
let rowHierarchy = pivotTable.addRowHierarchy(pivotTable.getHierarchy("Posting date"));
// Pivot table configuration
pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Project no."));
pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Name"));
pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Task No."));
// Dodanie wartości (Ilość)
let qtyHierarchy = pivotTable.getHierarchy("Time");
let dataField = pivotTable.addDataHierarchy(qtyHierarchy);
dataField.setSummarizeBy(ExcelScript.AggregationFunction.sum);
// Hiding subtotals for "Project No." and "Name"
// Alternate formatting (lines)
let pivotRange = pivotTable.getLayout().getRange();
let rowCount = pivotRange.getRowCount();
for (let i = 1; i < rowCount; i += 2) { // Every second line
let row = pivotRange.getCell(i, 0).getEntireRow();
row.getFormat().getFill();
}
console.log("The pivot table has been created.");
}
Gostaria que o total geral não fosse exibido e gostaria que as linhas e colunas fossem exibidas.