React Data GridExcel Export API Reference

Enterprise

This page documents the Excel Export API and Interfaces.

Grid Properties Copy Link

defaultExcelExportParamsCopy Link
A default configuration object used to export to Excel.
suppressExcelExportCopy Link
boolean
default: false
Prevents the user from exporting the grid to Excel.
A list (array) of Excel styles to be used when exporting to Excel with styles.

API Methods Copy Link

exportDataAsExcelCopy Link
Function
Downloads an Excel export of the grid's data.
getDataAsExcelCopy Link
Function
Similar to exportDataAsExcel, except instead of downloading a file, it will return a Blob to be processed by the user.
getSheetDataForExcelCopy Link
Function
This is method to be used to get the grid's data as a sheet, that will later be exported either by getMultipleSheetsAsExcel() or exportMultipleSheetsAsExcel().
exportMultipleSheetsAsExcelCopy Link
Function
Downloads an Excel export of multiple sheets in one file.
getMultipleSheetsAsExcelCopy Link
Function
Similar to exportMultipleSheetsAsExcel, except instead of downloading a file, it will return a Blob to be processed by the user.

Interfaces Copy Link

ExcelExportParams Copy Link

Properties available on the ExcelExportParams interface.

addImageToCellCopy Link
Function
Use to export an image for the gridCell in question.
allColumnsCopy Link
boolean
default: false
If true, all columns will be exported in the order they appear in the columnDefs. When false only the columns currently being displayed will be exported.
appendContentCopy Link
ExcelRow[]
Content to put at the top of the exported sheet. An array of ExcelRow objects, see Extra Content section.
authorCopy Link
string
default: "AG Grid"
The author of the exported file. @default "AG Grid"
autoConvertFormulasCopy Link
boolean
default: false
If set to true, this will try to convert any cell that starts with = to a formula, instead of setting the cell value as regular string that starts with =.
columnKeysCopy Link
(string | Column)[]
Provide a list (an array) of column keys or Column objects if you want to export specific columns.
columnWidthCopy Link
number | ((params: ColumnWidthCallbackParams) => number)
Defines the default column width. If no value is present, each column will have value currently set in the application with a min value of 75px. This property can also be supplied a callback function that returns a number.
exportAsExcelTableCopy Link
Used to add an Excel table to the spreadsheet. Set to true to use default export table config, or provide a config object. @default false
exportRowNumbersCopy Link
boolean
Set to true to allow the contents of the Header Row Column to be exported.
exportedRowsCopy Link
'all' | 'filteredAndSorted'
default: 'filteredAndSorted'
Determines whether rows are exported before being filtered and sorted.
fileNameCopy Link
string | ExportFileNameGetter
default: export.xlsx
String to use as the file name or a function that returns a string.
fontSizeCopy Link
number
default: 11
The default value for the font size of the Excel document.
freezeColumnsCopy Link
'pinned' | ExcelFreezeColumnsGetter
Use this property to select to freeze columns at the start of the grid (this will be the columns at the right for RTL).
  • pinned - Freeze all pinned left (right for RTL grids) columns.
  • A callback function that will freeze columns until a value other than true is returned. After that, this callback will no longer be executed.
  • freezeRowsCopy Link
    'headers' | 'headersAndPinnedRows' | ExcelFreezeRowsGetter
    Use this property to select to freeze rows at the top of the exported sheet.
  • headers - Freeze all grid headers at the top.
  • headersAndPinnedRows - Freeze all headers and pinned top rows.
  • A callback function that will freeze rows until a value other than true is returned, after that, this callback will no longer be executed. Note that using a callback will automatically freeze all header rows.
  • getCustomContentBelowRowCopy Link
    Function
    A callback function to return content to be inserted below a row in the export.
    The configuration for header and footers.
    headerRowHeightCopy Link
    number | ((params: RowHeightCallbackParams) => number)
    The height in pixels of header rows. Defaults to Excel default value. This property can also be supplied a callback function that returns a number.
    The Excel document page margins. Relevant for printing.
    mimeTypeCopy Link
    string
    default: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    The mimeType of the Excel file.
    onlySelectedCopy Link
    boolean
    default: false
    Export only selected rows.
    onlySelectedAllPagesCopy Link
    boolean
    default: false
    Only export selected rows including other pages (only makes sense when using pagination).
    Allows you to setup the page orientation and size.
    prependContentCopy Link
    ExcelRow[]
    Content to put at the bottom of the exported sheet. An array of ExcelRow objects, see Extra Content section.
    processCellCallbackCopy Link
    Function
    A callback function invoked once per cell in the grid. Return a string value to be displayed in the export. For example this is useful for formatting date values.
    processGroupHeaderCallbackCopy Link
    Function
    A callback function invoked once per column group. Return a string to be displayed in the column group header. Note that column groups are exported by default, this option will not work with skipColumnGroupHeaders=true.
    processHeaderCallbackCopy Link
    Function
    A callback function invoked once per column. Return a string to be displayed in the column header.
    processRowGroupCallbackCopy Link
    Function
    A callback function invoked once per row group. Return a string to be displayed in the group cell.
    rightToLeftCopy Link
    boolean
    default: undefined
    Use to set the direction for the worksheet.
  • true: Sets the direction to right-to-left (RTL).
  • false: Sets the direction to left-to-right (LTR).
  • undefined: Exports the worksheet according to the current direction of the grid as set by gridOptions.enableRtl.
  • rowGroupExpandStateCopy Link
    'expanded' | 'collapsed' | 'match'
    default: 'expanded'
    The expand/collapse state of each row group in the Excel Document.
  • expanded: All row groups will be expanded by default.
  • collapsed: All row groups will be collapsed by default.
  • match: The row groups will match their current state in the Grid.
  • rowHeightCopy Link
    number | ((params: RowHeightCallbackParams) => number)
    The height in pixels of all rows. Defaults to Excel default value. This property can also be supplied a callback function that returns a number.
    rowPositionsCopy Link
    RowPosition[]
    Row node positions.
    sheetNameCopy Link
    string | ExcelSheetNameGetter
    default: 'ag-grid'
    The name of the sheet in Excel where the grid will be exported. Either a string or a function that returns a string can be used. If a function is used, it will be called once before the export starts. There is a max limit of 31 characters per sheet name.
    shouldRowBeSkippedCopy Link
    Function
    A callback function that will be invoked once per row in the grid. Return true to omit the row from the export.
    skipColumnGroupHeadersCopy Link
    boolean
    default: false
    Set to true to exclude header column groups.
    skipColumnHeadersCopy Link
    boolean
    default: false
    Set to true if you don't want to export column headers.
    skipPinnedBottomCopy Link
    boolean
    default: false
    Set to true to suppress exporting rows pinned to the bottom of the grid.
    skipPinnedTopCopy Link
    boolean
    default: false
    Set to true to suppress exporting rows pinned to the top of the grid.
    skipRowGroupsCopy Link
    boolean
    default: false
    Set to true to skip row group headers if grouping rows. Only relevant when grouping rows.
    suppressColumnOutlineCopy Link
    boolean
    default: false.
    If true, the outline (controls to expand and collapse) for Group Columns will not be added automatically to the Excel Document.
    suppressRowOutlineCopy Link
    boolean
    default: false.
    If true, the outline (controls to expand and collapse) for Row Groups will not be added automatically to the Excel Document.

    ExcelExportMultipleSheetParams Copy Link

    Properties available on the ExcelExportMultipleSheetParams interface.

    See Multiple Sheets for more information.

    string[]
    Array of strings containing the raw data for Excel workbook sheets. This property is only used when exporting to multiple sheets using api.exportMultipleSheetsAsExcel() and the data for each sheet is obtained by calling api.getSheetDataForExcel().
    activeSheetIndexCopy Link
    number
    default: 0
    The index of the sheet to be marked as active by default.
    fileNameCopy Link
    string | ExportFileNameGetter
    default: 'export.xlsx'
    String to use as the file name or a function that returns a string.
    authorCopy Link
    string
    default: "AG Grid"
    The author of the exported file. @default "AG Grid"
    fontSizeCopy Link
    number
    default: 11
    The default value for the font size of the Excel document.
    mimeTypeCopy Link
    string
    default: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    The mimeType of the Excel file.

    ExcelAlignment Copy Link

    Properties available on the ExcelAlignment interface.

    horizontalCopy Link
    | 'Automatic' | 'Left' | 'Center' | 'Right' | 'Fill' | 'Justify' | 'CenterAcrossSelection' | 'Distributed' | 'JustifyDistributed'
    default: 'Automatic'
    Use this property to change the cell horizontal alignment.
    indentCopy Link
    number
    default: 0
    Use this property to change the level of indentation in the cell.
    readingOrderCopy Link
    'RightToLeft' | 'LeftToRight' | 'Context'
    default: 'LeftToRight'
    Use this property to change the cell reading order.
    rotateCopy Link
    number
    default: 0
    The number of degrees between 0 and 359 to rotate the text.
    shrinkToFitCopy Link
    boolean
    default: false
    If set to true, the font size of the cell will automatically change to force the text to fit within the cell.
    verticalCopy Link
    'Automatic' | 'Top' | 'Bottom' | 'Center' | 'Justify' | 'Distributed' | 'JustifyDistributed'
    default: 'Automatic'
    Use this property to change the cell vertical alignment.
    wrapTextCopy Link
    boolean
    default: false
    If set to true, multiline text will be displayed as multiline by Excel.

    ExcelBorders Copy Link

    Properties available on the ExcelBorders interface.

    Use to set the cell's bottom border.
    Use to set the cell's left border.
    Use to set the cell's right border.
    Use to set the cell's top border.

    ExcelBorder Copy Link

    Properties available on the ExcelBorder interface.

    string
    default: 'black'
    The color or the border.
    lineStyleCopy Link
    'None' | 'Continuous' | 'Dash' | 'Dot' | 'DashDot' | 'DashDotDot' | 'SlantDashDot' | 'Double'
    default: 'None'
    The style of the border.
    weightCopy Link
    0 | 1 | 2 | 3
    default: 0
    The thickness of the border from 0 (thin) to 3 (thick).

    ExcelCell Copy Link

    Properties available on the ExcelCell interface.

    The data that will be added to the cell.
    string
    Cell reference.
    collapsibleRangesCopy Link
    number[][]
    Collapsible ranges.
    styleIdCopy Link
    string | string[]
    The ExcelStyle id to be associated with the cell.
    mergeAcrossCopy Link
    number
    default: 0
    The number of cells to span across (1 means span 2 columns).

    ExcelData Copy Link

    Properties available on the ExcelData interface.

    type requiredCopy Link
    ExcelDataType | ExcelOOXMLDataType
    The type of data being in the cell.
    value requiredCopy Link
    string | null
    The value of the cell.

    ExcelFont Copy Link

    Properties available on the ExcelFont interface.

    boolean
    default: false
    Set to true to set the cell text to bold.
    string
    default: '#000000'
    The color of the cell font.
    familyCopy Link
    string
    default: 'Automatic'
    The family of the font to used in the cell. Options: Automatic,Roman,Swiss,Modern,Script,Decorative,
    fontNameCopy Link
    string
    default: 'Calibri'
    The name of the font to be used in the cell.
    italicCopy Link
    boolean
    default: false
    Set to true to display the cell font as italic.
    outlineCopy Link
    boolean
    default: false
    Set to true to add a text outline.
    shadowCopy Link
    boolean
    default: false
    Set to true to add text shadow.
    number
    Set this property to used a different font size other than the default.
    strikeThroughCopy Link
    boolean
    default: false
    Set to true to add a strikeThrough line.
    underlineCopy Link
    'Single' | 'Double'
    Use this property to underline the cell text.
    verticalAlignCopy Link
    'Superscript' | 'Subscript'
    Use this property to change the default font alignment. Note: This is different than setting cell vertical alignment.

    ExcelHeaderFooterConfig Copy Link

    Properties available on the ExcelHeaderFooterConfig interface.

    The configuration for header and footer on every page.
    The configuration for header and footer on the first page only.
    The configuration for header and footer on even numbered pages only.

    ExcelHeaderFooter Copy Link

    Properties available on the ExcelHeaderFooter interface. At least one of header or footer is required or both.

    An array of maximum 3 items (Left, Center, Right), containing header configurations.
    An array of maximum 3 items (Left, Center, Right), containing footer configurations.

    ExcelHeaderFooterContent Copy Link

    Properties available on the ExcelHeaderFooterContent interface.

    value requiredCopy Link
    string
    The value of the text to be included in the header.
    When value is &[Picture], this should be used as the referenced image.
    positionCopy Link
    'Left' | 'Center' | 'Right'
    default: 'Left'
    Configures where the text should be added: Left, Center or Right.
    The font style of the header/footer value.

    ExcelHeaderFooterImage Copy Link

    Properties available on the ExcelHeaderFooterImage interface.

    width requiredCopy Link
    number
    The width of the image in pixels.
    height requiredCopy Link
    number
    The height of the image in pixels.
    id requiredCopy Link
    string
    The image id. This field is required so the same image doesn't get imported multiple times.
    base64 requiredCopy Link
    string
    A base64 string that represents the image being imported.
    imageType requiredCopy Link
    'jpg' | 'png' | 'gif'
    The type of image being exported.
    recolorCopy Link
    'Grayscale' | 'Black & White' | 'Washout'
    Set this property to select a preset that changes the appearance of the image.
    brightnessCopy Link
    number
    The brightness of the image between 0 and 100 (if recolor is used, this value will only be applied for Grayscale). Default 50
    contrastCopy Link
    number
    The contrast of the image between 0 and 100. (If recolor is used, this value will only be applied for Grayscale.). Default 50
    altTextCopy Link
    string
    Alt Text for the image.

    ExcelImage Copy Link

    Properties available on the ExcelImage interface.

    id requiredCopy Link
    string
    The image id. This field is required so the same image doesn't get imported multiple times.
    base64 requiredCopy Link
    string
    A base64 string that represents the image being imported.
    imageType requiredCopy Link
    'jpg' | 'png' | 'gif'
    The type of image being exported.
    fitCellCopy Link
    boolean
    default: false
    If set to true, the image will cover the whole cell that is being imported to. This property does not apply to images in the Header/Footer
    transparencyCopy Link
    number
    default: 0
    Set a value between 0 - 100 that will indicate the percentage of transparency of the image.
    rotationCopy Link
    number
    default: 0
    Set a value between 0 - 359 that will indicate the number of degrees to rotate the image clockwise.
    recolorCopy Link
    'Grayscale' | 'Sepia' | 'Washout'
    Set this property to select a preset that changes the appearance of the image.
    number
    The width of the image in pixels. If this value is not selected, fitCell will be automatically set to true.
    heightCopy Link
    number
    The height of the image in pixels. If this value is not selected, fitCell will be automatically set to true.
    Position of the image.
    altTextCopy Link
    string
    Alt Text for the image.

    ExcelImagePosition Copy Link

    Properties available on the ExcelImagePosition interface.

    number
    The row containing this image. This property is set automatically, don't change it unless you know what you are doing.
    rowSpanCopy Link
    number
    default: 1
    The amount of rows this image will cover. @default 1
    columnCopy Link
    number
    The column containing this image. This property is set automatically, don't change it unless you know what you are doing.
    colSpanCopy Link
    number
    default: 1
    The amount of columns this image will cover.
    offsetXCopy Link
    number
    default: 0
    The amount in pixels the image should be offset horizontally.
    offsetYCopy Link
    number
    default: 0
    The amount in pixels the image should be offset vertically.

    ExcelInterior Copy Link

    Properties available on the ExcelInterior interface.

    patternCopy Link
    | 'None' | 'Solid' | 'Gray75' | 'Gray50' | 'Gray25' | 'Gray125' | 'Gray0625' | 'HorzStripe' | 'VertStripe' | 'ReverseDiagStripe' | 'DiagStripe' | 'DiagCross' | 'ThickDiagCross' | 'ThinHorzStripe' | 'ThinVertStripe' | 'ThinReverseDiagStripe' | 'ThinDiagStripe' | 'ThinHorzCross' | 'ThinDiagCross'
    Use this property to set background color patterns.
    string
    The colour to be used as a secondary colour combined with patterns.
    patternColorCopy Link
    string
    The pattern color.

    ExcelNumberFormat Copy Link

    Properties available on the ExcelNumberFormat interface.

    formatCopy Link
    string
    Use this property to provide a pattern to format a number. (eg. 10000 could become $10,000.00).

    ExcelProtection Copy Link

    Properties available on the ExcelProtection interface.

    protectedCopy Link
    boolean
    default: true
    Set to false to disable cell protection (locking)
    hideFormulaCopy Link
    boolean
    default: false
    Set to true to hide formulas within protected cells.

    ExcelSheetMargin Copy Link

    Properties available on the ExcelSheetMargin interface.

    number
    default: 0.75
    The sheet top margin.
    number
    default: 0.7
    The sheet right margin.
    bottomCopy Link
    number
    default: 0.75
    The sheet bottom margin.
    number
    default: 0.7
    The sheet left margin.
    headerCopy Link
    number
    default: 0.3
    The sheet header margin.
    number
    default: 0.3
    The sheet footer margin.

    ExcelSheetPageSetup Copy Link

    Properties available on the ExcelSheetPageSetup interface.

    orientationCopy Link
    'Portrait' | 'Landscape'
    default: 'Portrait'
    Use this property to change the print orientation.
    pageSizeCopy Link
    | 'Letter' | 'Letter Small' | 'Tabloid' | 'Ledger' | 'Legal' | 'Statement' | 'Executive' | 'A3' | 'A4' | 'A4 Small' | 'A5' | 'A6' | 'B4' | 'B5' | 'Folio' | 'Envelope' | 'Envelope DL' | 'Envelope C5' | 'Envelope B5' | 'Envelope C3' | 'Envelope C4' | 'Envelope C6' | 'Envelope Monarch' | 'Japanese Postcard' | 'Japanese Double Postcard'
    default: 'Letter'
    Use this property to set the sheet size.

    ExcelTableConfig Copy Link

    Properties available on the ExcelTableConfig interface.

    string
    default: 'AG-GRID-TABLE'
    This property is used to set the table name. It should be an alphanumeric string with no special characters.
    showFilterButtonCopy Link
    boolean | 'match'
    default: match
    Set this property to false to disable the filter button at the exported Excel table header. Set it to true to show the filter button on all columns. Set it to match to show the filter button only if the column has a filter allowed.
    showRowStripesCopy Link
    boolean
    default: true
    Set this property to false to hide the row stripes.
    showColumnStripesCopy Link
    boolean
    default: false
    Set this property to true to show column stripes.
    highlightFirstColumnCopy Link
    boolean
    default: false
    Set this property to true to show the first column in bold/highlighted style.
    highlightLastColumnCopy Link
    boolean
    default: false
    Set this property to true to show the last column in bold/highlighted style.

    ExcelStyle Copy Link

    Properties available on the ExcelStyle interface.

    id requiredCopy Link
    string
    The id of the Excel Style, this should match a CSS cell class.
    Use this property to customise cell alignment properties.
    Use this property to customise cell borders.
    Use this property to specify the type of data being exported.
    Use this property to customise the font used in the cell.
    Use this property to customise the cell background.
    Use this property to customise the cell value as a formatted number.
    Use this property to setup cell protection.

    Types Copy Link

    ExcelDataType Copy Link

    type ExcelDataType = 
        'String'   |
        'Formula'  |
        'Number'   |
        'Boolean'  |
        'DateTime' |
        'Error'
    

    ExcelOOXMLDataType Copy Link

    type ExcelOOXMLDataType = 
        'str'       |
        's'         |
        'f'         |
        'inlineStr' |
        'n'         |
        'b'         |
        'd'         |
        'e'         |
        'empty'