-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample01.ts
More file actions
35 lines (29 loc) · 1.08 KB
/
Copy pathexample01.ts
File metadata and controls
35 lines (29 loc) · 1.08 KB
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
import { downloadExcelFile, Workbook } from 'excel-builder-vanilla';
import './example01.scss';
export default class Example {
exportBtnElm!: HTMLButtonElement;
mount() {
this.exportBtnElm = document.querySelector('#export') as HTMLButtonElement;
this.exportBtnElm.addEventListener('click', this.startProcess.bind(this));
}
unmount() {
// remove event listeners to avoid DOM leaks
this.exportBtnElm.removeEventListener('click', this.startProcess.bind(this));
}
startProcess() {
const originalData = [
['Artist', 'Album', 'Price'],
['Buckethead', 'Albino Slug', 8.99],
['Buckethead', 'Electric Tears', 13.99],
['Buckethead', 'Colma', 11.34],
['Crystal Method', 'Vegas', 10.54],
['Crystal Method', 'Tweekend', 10.64],
['Crystal Method', 'Divided By Night', 8.99],
];
const artistWorkbook = new Workbook();
const albumList = artistWorkbook.createWorksheet({ name: 'Artists' });
albumList.setData(originalData);
artistWorkbook.addWorksheet(albumList);
downloadExcelFile(artistWorkbook, 'Artist WB.xlsx');
}
}