Configuring Export

View as Markdown

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:

PropertySection
exportDataFormatFormatting Report Data
exportDateFormatFormatting Report Data
customDestinationsCustom Export Destinations
systemReportNamesReports
systemReportFormatsReport Format Types
systemExportDestinationsExport Destinations
appendFileTimestampConfiguring Report File Names
reportFilenameConfiguring Report File Names
isColumnExportableSetting Exportable Columns
csvSeparatorReport Format Type — CSV
skipColumnHeadersSkipping Column Headers
getDetailRowsExporting Detail Rows
processExportProcessing Reports
excelSheetNameReport 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 exportConfig argument of the exportReport function 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: Freezing
  • freezeColumns - freezes the left pinned columns ('pinned')
  • protectSheet - protects the worksheet, optionally with a password; see Excel Export: Data Protection
  • author, fontSize, headerRowHeight and rowHeight
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 Params
Promise<void>
Exports a Report (with fine-grained control if needed)
Configuring Export
Fork
  • In this demo we export data to Excel and CSV via the exportReport function in Export API (using Custom Toolbar Buttons), allowing us add bespoke config:
    • We export Current Layout report to Excel, with custom names for Excel Workbook and Worksheet, and changing font and header row height
    • We export All Data report to CSV, with custom filename and separator
Loading demo…

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:

  • appendFileTimestamp which appends a Timestamp to the Report name

appendFileTimestamp

Default: false
boolean
Whether to add a timestamp as a suffix to exported file name
  • reportFilename which allows a completely different Report name to be used

reportFilename

(reportFileNameContext: ReportFileNameContext) => string
Function enabling bespoke Report file names
Configuring Report FileNames
Fork
  • In this example we provide a custom File Name - but just for the "All Data" Report
Loading demo…

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: true
boolean
Whether a Column is exportable
Setting Exportable Columns
Fork
  • In this example we dont export the Language Column, nor any Date Columns
Loading demo…

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: false
boolean
Whether to exclude Column Headers from the exported data
Skipping Column Headers
Fork
  • In this example we exclude Custom Headers from the "All Data" Report only
Loading demo…

Find Out More

Master–detail grids need getDetailRows to include detail rows in an export — see Exporting Detail Rows.