jQuery/JS Common - Object Structures - ExcelExportDataGridProps
Properties that can be passed to the exportDataGrid(options) method from the excelExporter module.
autoFilterEnabled
Specifies whether to enable Excel filtering in the document.
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: |
|
gridCell |
A DataGrid cell. |
The following code illustrates how to customize font and alignment in cells whose rowType equals "data":
- $(function() {
- $("#dataGridContainer").dxDataGrid({
- // ...
- export: {
- enabled: true
- },
- onExporting(e) {
- const workbook = new ExcelJS.Workbook();
- const worksheet = workbook.addWorksheet('Companies');
- DevExpress.excelExporter.exportDataGrid({
- component: e.component,
- worksheet: worksheet,
- topLeftCell: { row: 2, column: 2 },
- customizeCell: function(options) {
- var { gridCell, excelCell } = options;
- if(gridCell.rowType === 'data') {
- 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");
- });
- });
- }
- });
- });
- <head>
- <!-- ... -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.0/polyfill.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.4.0/exceljs.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.2/FileSaver.min.js"></script>
- <!-- reference the DevExtreme sources here -->
- </head>
encodeExecutableContent
Exported spreadsheet documents can be unsafe because executable content (such as formulas) may include malicious code. A spreadsheet application can execute this code if a user opens such a file and confirms that the application can load and execute dynamic content.
Enable this property to ensure that exported CSV files are safe for loading in third-party spreadsheet applications.
topLeftCell
The cell is specified using coordinates in the Excel document. For example, the following code specifies cell B2:
- DevExpress.excelExporter.exportDataGrid({
- // ...
- topLeftCell: { row: 2, column: 2 }
- });
You can also specify the topLeftCell using the Excel notation:
- DevExpress.excelExporter.exportDataGrid({
- // ...
- 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.