Yes—AG Grid can export grid data to an Excel workbook (.xlsx) using its Excel Export feature. In JavaScript, call gridApi.exportDataAsExcel() to download a workbook; Excel export is an AG Grid Enterprise feature, while AG Grid Community provides CSV export.
What AG Grid Excel export does
AG Grid builds an Excel workbook from the grid’s data and configuration. It does not take a picture of the screen: the exported workbook contains rows, columns, values, and supported formatting that Excel can work with. This makes the feature useful when people need to sort or filter the exported data, apply their own calculations, or share a structured report.
The export is usually a single-sheet .xlsx file. Its contents can reflect grid features such as column definitions, value formatters, grouping, and row selection, subject to the export options and the row model in use. It is not a guarantee that every on-screen detail will appear exactly as displayed. For example, custom cell-renderer visuals and interactive controls are not screenshots and do not automatically become Excel content.
Requirements and licensing
Excel export belongs to AG Grid Enterprise. A Community-only installation does not gain the feature merely by calling the API; use the Community CSV export instead, or use an Enterprise package and a valid license for the application. Check the licensing terms that apply to your project before shipping the feature.
AG Grid supports both package setups that register individual modules and setups that include a broader set of modules. In a modular application, ensure the Excel Export module is included and registered for the AG Grid version you have installed. Package names and registration conventions can change between major releases, so follow the documentation for that exact version rather than copying an import from a different release. If the API is missing or the grid reports a module-related error, module registration is one of the first things to check.
Basic implementation
After the grid is created and its API is available, call the export method in response to a button click or another user action. A typical setup looks like this:
const exportButton = document.querySelector('#export-excel');
exportButton.addEventListener('click', () => {
gridApi.exportDataAsExcel({
fileName: 'orders.xlsx'
});
});
The example assumes gridApi refers to the API for the live grid. In React, Angular, Vue, or another framework, obtain the API using the grid’s documented lifecycle or event mechanism for that framework; do not assume it exists before the grid has initialized. The button itself is ordinary application UI, not a built-in requirement of Excel export.
exportDataAsExcel(params) initiates a browser download. AG Grid also provides getDataAsExcel(params), which returns the workbook as a Blob rather than immediately triggering the normal download. That can be useful when an application needs to pass the file to another browser-side workflow. It does not, by itself, upload or email the workbook; those actions require separate application code and appropriate server-side handling.
Choosing which rows and columns to export
Export scope matters because the grid can show only part of the underlying dataset. By default, AG Grid’s export behavior is not necessarily the same as “whatever is visible right now.” For example, the default row export includes all rows; use the export options when the desired report should instead follow the current filter and sort state. Options such as exportedRows, columnKeys, and onlySelected help define the output.
- To export only certain columns, supply their column keys with
columnKeys. This is useful for reports that should omit internal identifiers or operational fields. - To export selected records, use
onlySelected: true. Confirm that selection is meaningful in your grid and that the user understands whether the selection covers the current page or a larger dataset. - To follow filtering and sorting, configure the exported row behavior rather than assuming the default matches the visible subset.
- To omit special rows, such as a pinned summary row, review the relevant export parameters for pinned top and bottom rows.
Pagination is another source of confusion: a page is a view of the data, not automatically a definition of the full export. The exact result can also depend on the row model. With a server-side or other non-client-side row model, confirm the behavior against the documentation for that model and AG Grid version; do not promise users that every record on the server will be included just because the grid displays a page of results.
Values, headers, and formatting
Excel export uses the grid’s data and supported export rules, not the pixels rendered in each cell. A value formatter is generally used for exported values unless export behavior is configured otherwise. A custom cell renderer, by contrast, is for presenting content in the grid and is not automatically converted into a workbook value. If a rendered cell shows a button, icon, or elaborate combination of elements, decide what plain value or text should represent it in Excel.
For a value that needs special export treatment, AG Grid provides callbacks such as processCellCallback and processHeaderCallback. These let the application adapt a cell or header value during export—for example, replacing a display label with a more suitable report label. Use such callbacks deliberately: an export callback can change what users receive even though the grid continues to display the original value.
Excel-specific styling can be configured with AG Grid’s Excel style options, including excelStyles and matching style IDs assigned through the grid’s cell classes. This is separate from ordinary CSS. A CSS color or layout rule does not automatically become an Excel fill, font, or number format. Plan workbook formatting explicitly, and check the generated file in Excel if number formats, dates, or grouped rows are important to the report.
Common problems and how to diagnose them
If clicking an export button does nothing, check the browser console and the grid’s setup before changing the data. Typical causes include using Community rather than Enterprise, failing to register the export module in a modular build, calling the API before the grid is ready, or using an API name or option copied from documentation for a different AG Grid release.
- The downloaded file is missing records: inspect filters, row selection, pagination, the configured row model, and the export row options. Test with a small, known dataset.
- A column contains unexpected text: check its field or value getter, value formatter, and any export callback. The grid’s visible renderer may not be the value that export uses.
- Formatting is absent: verify that Excel styles are configured using AG Grid’s Excel styling mechanism, rather than relying only on CSS.
- The workbook has a license notice or feature warning: confirm that the Enterprise feature is properly licensed and that the application’s license setup matches its deployment.
- Large exports are slow or unwieldy: consider whether the user needs every column and row, and whether a server-generated report or a filtered export is a better fit.
When diagnosing a mismatch, compare three things: the underlying row data, the values AG Grid displays, and the values in the workbook. A difference between those layers often reveals whether the cause is data preparation, a formatter or renderer, or export configuration.
Excel export compared with CSV
CSV is a plain-text table format. It is widely supported and often suitable for moving simple rows and columns between systems. AG Grid Community includes CSV export; AG Grid Enterprise adds Excel workbook export. An .xlsx workbook can carry Excel-specific formatting and richer workbook structure, whereas CSV does not preserve those features.
Choose CSV when a downstream system expects delimited text or when simple portability is the priority. Choose Excel export when recipients need a workbook and the report benefits from supported styles or workbook-oriented features. Neither format should be treated as a security boundary. If exported data includes confidential fields, remove or restrict those fields before producing the file, regardless of format.
Practical design and data considerations
Before adding an export button, define what the report is meant to represent. A user may interpret “Export to Excel” as the currently filtered results, the selected records, the current page, or the entire dataset. Give the control a clear label or explanation when the behavior is not obvious, and consider setting a meaningful filename so downloads are easier to identify.
Also review which data is safe and useful to export. A hidden column is not necessarily a reliable way to protect sensitive information; configure the export’s included columns deliberately. If the grid contains values derived from user input or external sources, treat them as data that may be opened in a spreadsheet application and follow your organization’s data-handling practices. For very large reports, an asynchronous server-side report may be more appropriate than asking a browser tab to build and download a large workbook.
Frequently Asked Questions
Can AG Grid export to Excel for free?
Excel export is an AG Grid Enterprise feature. AG Grid Community offers CSV export, which may be enough when a plain-text table is acceptable. Check the current licensing terms for your use case.
What method downloads the Excel file?
Use gridApi.exportDataAsExcel(), optionally passing export parameters such as a filename or selected columns. The method is available when the Enterprise Excel Export feature is correctly installed and configured.
Does the export include filtered rows only?
Not necessarily. The default export includes all rows. Configure the exported row behavior if the intended output is the filtered and sorted result, and verify how that setting interacts with your row model.
Will custom cell renderers appear in Excel?
Not as rendered interface elements. Export is based on values and export callbacks, not a screenshot of the grid. Provide a suitable exported value or use a processing callback when the displayed renderer needs a different spreadsheet representation.
Can AG Grid export only selected columns or rows?
Yes. Export parameters support limiting columns with columnKeys and exporting selected rows with onlySelected. Test the resulting scope, especially when selection and pagination are both enabled.
Related
- Excel Export CSV With Headers: How It Works
- Excel Export CSV With Quotes: How It Works
- Excel Export to Tab-Delimited CSV: How to Save It Correctly
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Average Growth Rate in Excel: Calculate It Step by StepTo calculate the arithmetic average of period-by-period growth rates in Excel, calculate each rate in a helper column,…
- How to Add a Shared Mailbox in Outlook for iOS AppTo add a shared mailbox in Outlook for iOS, sign in with the work or school account that…
- Freeze Panes in Excel 365: Keep Rows and Columns VisibleTo freeze panes in Excel 365 for Windows, select the cell immediately below the rows and to the…
- How to Set an Out of Office Reply in OutlookTo set an out-of-office reply in Outlook, open Automatic Replies, turn them on, write your message, and—if available—choose…
- Copy Paste in Excel: Keep Column Widths When PastingIn Excel for Microsoft 365 on Windows, copying cells does not normally copy their column widths. To match…
- Excel Shortcut for Filtering a Table: Keys and TipsIn Excel for Microsoft 365 on Windows, press Ctrl+Shift+L to turn filter buttons on or off for the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.