-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (64 loc) · 1.71 KB
/
index.js
File metadata and controls
65 lines (64 loc) · 1.71 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
$(() => {
$('#pivot-grid').dxPivotGrid({
dataSource: {
store: {
type: 'xmla',
url: 'https://demos.devexpress.com/Services/OLAP/msmdpump.dll',
catalog: 'Adventure Works DW Standard Edition',
cube: 'Adventure Works',
},
fields: [{
dataField: '[Product].[Category]',
area: 'row',
sortBySummaryField: '[Measures].[Sales Amount]',
sortOrder: 'desc',
}, {
dataField: '[Product].[Subcategory]',
area: 'row',
sortBySummaryField: '[Measures].[Sales Amount]',
sortOrder: 'desc',
}, {
dataField: '[Ship Date].[Calendar Year]',
area: 'column',
filterValues: [['CY 2003'], ['CY 2004']],
}, {
dataField: '[Ship Date].[Month of Year]',
area: 'column',
}, {
dataField: '[Measures].[Sales Amount]',
area: 'data',
format: 'currency',
}, {
dataField: '[Measures].[Tax Amount]',
area: 'data',
format: 'currency',
}],
},
allowSorting: true,
allowSortingBySummary: true,
allowFiltering: true,
fieldPanel: {
visible: true,
showFilterFields: false,
},
fieldChooser: {
allowSearch: true,
},
export: {
enabled: true,
},
onExporting(e) {
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('Sales');
DevExpress.excelExporter.exportPivotGrid({
component: e.component,
worksheet,
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'Sales.xlsx');
});
});
e.cancel = true;
},
});
});