-
Notifications
You must be signed in to change notification settings - Fork 1
Open
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",
columns: [
{ name: "A" },
{ name: "B" },
{ name: "C" },
{ name: "D" },
{ name: "E" },
],
rows: [
["a1", "b1", "c1", 4, 5],
["a1", "b2", "c1", 4, 5],
["a2", "b1", "c2", 14, 24],
["a2", "b2", "c2", 24, 35],
["a3", "b1", "c3", 34, 45],
["a3", "b2", "c3", 44, 45],
],
});
const worksheet2 = workbook.addWorksheet("Sheet2");
worksheet2.addPivotTable({
sourceTable: table,
rows: ["A", "B"],
columns: ["C"],
values: ["E"], // Exactly 1 field
metric: "sum", // Metric: 'sum' only
});Metadata
Metadata
Assignees
Labels
No labels