Vue Common - Object Structures - ExcelExportPivotGridProps
Properties that can be passed to the exportPivotGrid(options) method from the excelExporter module.
customizeCell
Name | Type | Description |
---|---|---|
excelCell |
An ExcelJS object that describes an Excel cell. Use the object's properties to customize the cell. For information on these properties, refer to the following ExcelJS documentation sections: |
|
pivotCell |
A PivotGrid cell. |
In the following code, the customizeCell function customizes font and alignment in cells that display regular summaries (whose rowType is "D"):
- <template>
- <DxPivotGrid ...
- @exporting="onExporting">
- <DxExport
- :enabled="true"
- />
- </DxPivotGrid>
- </template>
- <script>
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import { DxPivotGrid, DxExport } from 'devextreme-vue/pivot-grid';
- import { exportPivotGrid } from 'devextreme/excel_exporter';
- import { Workbook } from 'exceljs';
- import saveAs from 'file-saver';
- export default {
- components: {
- DxPivotGrid,
- DxExport
- },
- methods: {
- onExporting(e) {
- const workbook = new Workbook();
- const worksheet = workbook.addWorksheet('Companies');
- exportPivotGrid({
- component: e.component,
- worksheet: worksheet,
- topLeftCell: { row: 2, column: 2 },
- customizeCell: function(options) {
- const { pivotCell, excelCell } = options;
- if(pivotCell.rowType === 'D') {
- excelCell.font = { color: { argb: 'FF0000FF' }, underline: true };
- excelCell.alignment = { horizontal: 'left' };
- }
- }
- }).then(function() {
- workbook.xlsx.writeBuffer().then(function(buffer) {
- saveAs(new Blob([buffer], { type: "application/octet-stream" }), "Companies.xlsx");
- });
- });
- e.cancel = true;
- }
- }
- }
- </script>
topLeftCell
The cell is specified using coordinates in the Excel document. For example, the following code specifies cell B2:
- DevExpress.excelExporter.exportPivotGrid({
- // ...
- topLeftCell: { row: 2, column: 2 }
- });
You can also specify the topLeftCell using the Excel notation:
- DevExpress.excelExporter.exportPivotGrid({
- // ...
- topLeftCell: "B2"
- });
worksheet
A worksheet is a part of a workbook. Refer to the ExcelJS documentation for information on how to create a workbook and add a worksheet to it.
If you have technical questions, please create a support ticket in the DevExpress Support Center.