-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.vue
69 lines (64 loc) · 1.63 KB
/
App.vue
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
66
67
68
69
<template>
<DxPivotGrid
id="pivotGrid"
:data-source="dataSource"
:allow-sorting="true"
:allow-sorting-by-summary="true"
:allow-filtering="true"
@exporting="exportGrid">
<DxFieldPanel
:visible="true"
:show-filter-fields="false"
/>
<DxFieldChooser :allow-search="true" />
<DxExport :enabled="true" />
</DxPivotGrid>
</template>
<script>
import 'devextreme/dist/css/dx.common.css';
import 'devextreme/dist/css/dx.light.css'
import {
DxPivotGrid,
DxFieldPanel,
DxFieldChooser,
DxExport
} from 'devextreme-vue/pivot-grid';
import AdventureWorksService from './adventureworks.service';
import { exportPivotGrid } from 'devextreme/excel_exporter';
import { Workbook } from 'exceljs';
import saveAs from 'file-saver';
export default {
name: 'Getting Started with DevExtreme PivotGrid',
components: {
DxPivotGrid,
DxFieldPanel,
DxFieldChooser,
DxExport
},
data() {
return {
dataSource: AdventureWorksService.getPivotGridDataSource()
}
},
methods: {
exportGrid (e) {
const workbook = new Workbook();
const worksheet = workbook.addWorksheet('Sales');
exportPivotGrid({
component: e.component,
worksheet: worksheet
}).then(function() {
workbook.xlsx.writeBuffer().then(function(buffer) {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'Sales.xlsx');
});
});
e.cancel = true;
}
}
}
</script>
<style>
#pivotGrid {
height: 70vh;
}
</style>