-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
🚀 Feature Proposal
The "Summarise with Pivot Table" functionality for a table.
Motivation
Pivot tables are a great way of summarising data for tables.
Example
Inspired by exceljs/exceljs#2551. Notice the sourceTable property for Worksheet.addPivotTable().
import { Workbook } from "@cj-tech-master/excelts";
const workbook = new Workbook();
const worksheet = workbook.addWorksheet();
const table = worksheet.addTable({
name: "table",
ref: "A1",
headerRow: true,
columns: [
{ name: "A" },
{ name: "B" },
{ name: "C" },
],
rows: [
["a1", "b1", 5],
["a1", "b2", 5],
["a2", "b1", 24],
["a2", "b2", 35],
["a3", "b1", 45],
["a3", "b2", 45],
],
});
const worksheet2 = workbook.addWorksheet("Sheet2");
worksheet2.addPivotTable({
sourceTable: table,
rows: ["A"],
columns: ["B"],
values: ["C"], // Exactly 1 field
metric: "sum", // Metric: 'sum' only
});
workbook.xlsx.writeFile("./test.xlsx");Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels