What is @ag-grid-enterprise/excel-export?
@ag-grid-enterprise/excel-export is a package that allows you to export data from AG Grid to Excel. It provides a range of features to customize the export process, including styling, formatting, and the ability to export specific data ranges.
What are @ag-grid-enterprise/excel-export's main functionalities?
Basic Export
This feature allows you to export the entire grid data to an Excel file with a single button click.
const gridOptions = {
columnDefs: [
{ field: 'make' },
{ field: 'model' },
{ field: 'price' }
],
rowData: [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
]
};
document.querySelector('#exportButton').addEventListener('click', () => {
gridOptions.api.exportDataAsExcel();
});
Customizing Export
This feature allows you to customize the export file name and sheet name.
const gridOptions = {
columnDefs: [
{ field: 'make' },
{ field: 'model' },
{ field: 'price' }
],
rowData: [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
]
};
document.querySelector('#exportButton').addEventListener('click', () => {
gridOptions.api.exportDataAsExcel({
fileName: 'custom_export.xlsx',
sheetName: 'Custom Sheet'
});
});
Styling Cells
This feature allows you to apply custom styles to specific cells during the export process.
const gridOptions = {
columnDefs: [
{ field: 'make' },
{ field: 'model' },
{ field: 'price' }
],
rowData: [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
],
defaultExcelExportParams: {
processCellCallback: (params) => {
if (params.column.getColId() === 'price') {
return { value: params.value, style: { font: { bold: true } } };
}
return params.value;
}
}
};
document.querySelector('#exportButton').addEventListener('click', () => {
gridOptions.api.exportDataAsExcel();
});
Other packages similar to @ag-grid-enterprise/excel-export
xlsx
The 'xlsx' package is a popular library for reading and writing Excel files in JavaScript. It provides a wide range of functionalities for manipulating Excel files, including creating new files, reading existing files, and modifying cell values. Compared to @ag-grid-enterprise/excel-export, 'xlsx' offers more low-level control over Excel file manipulation but requires more effort to integrate with data grids.
exceljs
The 'exceljs' package is another powerful library for working with Excel files in JavaScript. It supports creating and formatting Excel files, including adding images, tables, and charts. 'exceljs' provides more advanced features for Excel file manipulation compared to @ag-grid-enterprise/excel-export, but it also requires more detailed configuration and coding.
sheetjs-style
The 'sheetjs-style' package is an extension of the 'xlsx' package that adds support for cell styling. It allows you to apply styles to cells, such as fonts, colors, and borders. While 'sheetjs-style' offers more advanced styling options compared to @ag-grid-enterprise/excel-export, it is less integrated with data grid libraries and requires more manual setup.
AG Grid Enterprise
This project contains AG Grid Enterprise features.
See www.ag-grid.com for an overview and full documentation.
Frameworks Supported
Framework specific Getting Started guides:
Angular | Javascript | React | TypeScript | VueJS
This is not free software, this software is covered by copyright and to use you need a commercial license.
Please see files:
LICENSE.md
SUPPORT_AND_MAINTENANCE.md
Issue Reporting
If you are an Enterprise customer (or are evaluating AG Grid Enterprise) and wish to report a Bug or raise a new Feature Request please do so on our Support Portal.
To Sign Up:
Send an email to accounts@ag-grid.com with your license key