-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPivotGridContent.vue
More file actions
54 lines (49 loc) · 1.33 KB
/
PivotGridContent.vue
File metadata and controls
54 lines (49 loc) · 1.33 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
<script setup lang="ts">
import {
DxPivotGrid,
DxFieldPanel,
DxFieldChooser,
DxExport,
} from 'devextreme-vue/pivot-grid';
import type { DxPivotGridTypes } from 'devextreme-vue/pivot-grid';
import AdventureWorksService from '../adventureworks.service';
import { exportPivotGrid } from 'devextreme/excel_exporter';
import { Workbook } from 'devextreme-exceljs-fork';
import { saveAs } from 'file-saver';
const dataSource = AdventureWorksService.getPivotGridDataSource() as any;
const handleExporting = (e: DxPivotGridTypes.ExportingEvent): void => {
const workbook = new Workbook();
const worksheet = workbook.addWorksheet('Sales');
exportPivotGrid({
component: e.component,
worksheet,
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'Sales.xlsx');
});
});
e.cancel = true;
};
</script>
<template>
<DxPivotGrid
id="pivot-grid"
:data-source="dataSource"
:allow-sorting="true"
:allow-sorting-by-summary="true"
:allow-filtering="true"
@exporting="handleExporting"
>
<DxFieldPanel
:visible="true"
:show-filter-fields="false"
/>
<DxFieldChooser :allow-search="true"/>
<DxExport :enabled="true"/>
</DxPivotGrid>
</template>
<style scoped>
#pivot-grid {
height: 70vh;
}
</style>