-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest-chart.js
54 lines (47 loc) · 1.13 KB
/
test-chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const Excel = require('../lib/exceljs.nodejs.js');
const HrStopwatch = require('./utils/hr-stopwatch');
const [, , filename] = process.argv;
const wb = new Excel.Workbook();
const ws = wb.addWorksheet('Foo');
const now = Date.now();
const today = now - (now % 86400000);
const getRows = () => {
const rows = [];
for (let i = 0; i < 20; i++) {
rows.push([new Date(today + (86400000 * i)), Math.random() * 10]);
}
return rows;
};
ws.columns = [{key: 'date', width: 16}, {key: 'number'}];
ws.addTable({
name: 'TestTable',
ref: 'A1',
headerRow: true,
totalsRow: true,
style: {
theme: 'TableStyleDark3',
showRowStripes: true,
},
columns: [
{name: 'Date', totalsRowLabel: 'Max:', filterButton: true},
{
name: 'Value',
totalsRowFunction: 'max',
filterButton: true,
totalsRowResult: 8,
},
],
rows: getRows(),
});
const stopwatch = new HrStopwatch();
stopwatch.start();
wb.xlsx
.writeFile(filename)
.then(() => {
const micros = stopwatch.microseconds;
console.log('Done.');
console.log('Time taken:', micros);
})
.catch(error => {
console.log(error.message);
});