Configuring Export
Summary
- Developers can configure Export at design time in multiple ways
There are many aspects of Export that can be configured by developers, primarily through properties in Export Options, or functions in Export API.
ExportOptions defines fourteen properties:
| Property | Section |
|---|---|
exportDataFormat | Formatting Report Data |
exportDateFormat | Formatting Report Data |
customDestinations | Custom Export Destinations |
systemReportNames | Reports |
systemReportFormats | Report Format Types |
systemExportDestinations | Export Destinations |
appendFileTimestamp | Configuring Report File Names |
reportFilename | Configuring Report File Names |
isColumnExportable | Setting Exportable Columns |
csvSeparator | Report Format Type — CSV |
skipColumnHeaders | Skipping Column Headers |
getDetailRows | Exporting Detail Rows |
processExport | Processing Reports |
excelSheetName | Report Format Type — Excel |
Advanced Exporting
By default Export will send the report to the desired destination in a straightforward way.
For instance exporting to Excel will create a new workbook with default worksheet settings.
However sometimes users want more fine-grained control over the Exported file, e.g. to freeze the header row, protect the worksheet, or change the font in Excel.
There are 2 ways to provide this:
- for every Export, through AG Grid's default export params
- for a single Export, through the
exportConfigargument of theexportReportfunction in Export API
AG Grid Default Export Params
AG Grid's defaultExcelExportParams and defaultCsvExportParams GridOptions properties provide settings for every Excel and CSV Export (see Excel Export API and CSV Export).
AdapTable applies them to all Exports, wherever they are run from (e.g. the Export Toolbar, Context Menu, Export API or a Scheduled Report), and to the convertToExcel and convertToCsv functions used in Processing Reports.
Commonly used Excel settings include:
freezeRows- freezes the header row ('headers'), or the header row and the top pinned rows ('headersAndPinnedRows'); see Excel Export: FreezingfreezeColumns- freezes the left pinned columns ('pinned')protectSheet- protects the worksheet, optionally with a password; see Excel Export: Data Protectionauthor,fontSize,headerRowHeightandrowHeight
const gridOptions: GridOptions = {
defaultExcelExportParams: {
freezeRows: 'headers',
freezeColumns: 'pinned',
protectSheet: true,
},
defaultCsvExportParams: {
prependContent: 'Trades Report',
},
};Note
AdapTable sets the exported columns, rows and cell values, the file name, the sheet name and the CSV separator for every Export, so these params are ignored in the default export params: columnKeys, exportedRows, shouldRowBeSkipped, skipRowGroups, rowGroupExpandState, fileName, skipColumnHeaders, getCustomContentBelowRow, processCellCallback, processRowGroupCallback, sheetName, processNoteCallback and columnSeparator.
Use the Export Options instead (e.g. reportFilename, skipColumnHeaders, excelSheetName and csvSeparator), or exportConfig for a single Export.
The convertToExcel and convertToCsv functions also use the skipColumnHeaders, excelSheetName and csvSeparator Export Options.
Note
JSON Exports ignore defaultCsvExportParams
Note
convertToExcel creates the file from the Report Data only, which has no pinned columns or pinned rows, so there freezeColumns: 'pinned' freezes nothing and freezeRows: 'headersAndPinnedRows' freezes only the header row
Export Config
The exportReport function in Export API takes an optional exportConfig argument which allows developers to modify the params of a single Export.
Params set here override both AdapTable's params and AG Grid's default export params (they are not used when processExport returns the Report itself).
exportReport
Multiple ParamsPromise<void>- In this demo we export data to Excel and CSV via the
exportReportfunction in Export API (using Custom Toolbar Buttons), allowing us add bespoke config:- We export
Current Layoutreport to Excel, with custom names for Excel Workbook and Worksheet, and changing font and header row height - We export
All Datareport to CSV, with custom filename and separator
- We export
Configuring Report File Names
By default the name of the file created in an Export is that of the exported Report Name (e.g. 'All Data').
There are 2 options available in Export Options to change this behaviour:
appendFileTimestampwhich appends a Timestamp to the Report name
appendFileTimestamp
Default: falsebooleanreportFilenamewhich allows a completely different Report name to be used
reportFilename
(reportFileNameContext: ReportFileNameContext) => string- In this example we provide a custom File Name - but just for the "All Data" Report
Setting Exportable Columns
By default every Column in AdapTable is exportable.
This means that it can be included in System Reports (e.g. All Data) and will be available in UI for selection.
This can be set to false for any Column via the isColumnExportable property in Export Options.
isColumnExportable
Default: trueboolean- In this example we dont export the
LanguageColumn, nor anyDateColumns
Skipping Column Headers
By default AdapTable will include the Column Headers in the Export.
This can be set to false all or some Reports via the skipColumnHeaders property in Export Options.
skipColumnHeaders
Default: falseboolean- In this example we exclude Custom Headers from the "All Data" Report only
Find Out More
Master–detail grids need getDetailRows to include detail rows in an export — see Exporting Detail Rows.