MCPcopy
hub / github.com/exceljs/exceljs / main

Function main

test/test-pivot-table.js:9–39  ·  view source on GitHub ↗
(filepath)

Source from the content-addressed store, hash-verified

7/* eslint-disable */
8
9function main(filepath) {
10 const Excel = require('../lib/exceljs.nodejs.js');
11
12 const workbook = new Excel.Workbook();
13
14 const worksheet1 = workbook.addWorksheet('Sheet1');
15 worksheet1.addRows([
16 ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],
17 ['a1', 'b1', 'c1', 'd1', 'e1', 'f1', 4, 5],
18 ['a1', 'b2', 'c1', 'd2', 'e1', 'f1', 4, 5],
19 ['a2', 'b1', 'c2', 'd1', 'e2', 'f1', 14, 24],
20 ['a2', 'b2', 'c2', 'd2', 'e2', 'f2', 24, 35],
21 ['a3', 'b1', 'c3', 'd1', 'e3', 'f2', 34, 45],
22 ['a3', 'b2', 'c3', 'd2', 'e3', 'f2', 44, 45],
23 ]);
24
25 const worksheet2 = workbook.addWorksheet('Sheet2');
26 worksheet2.addPivotTable({
27 // Source of data: the entire sheet range is taken;
28 // akin to `worksheet1.getSheetValues()`.
29 sourceSheet: worksheet1,
30 // Pivot table fields: values indicate field names;
31 // they come from the first row in `worksheet1`.
32 rows: ['A', 'B', 'E'],
33 columns: ['C', 'D'],
34 values: ['H'], // only 1 item possible for now
35 metric: 'sum', // only 'sum' possible for now
36 });
37
38 save(workbook, filepath);
39}
40
41function save(workbook, filepath) {
42 const HrStopwatch = require('./utils/hr-stopwatch');

Callers 1

Calls 4

addWorksheetMethod · 0.95
addPivotTableMethod · 0.80
saveFunction · 0.70
addRowsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…