@progress/kendo-react-excel-export
Version:
React Excel export helps you export and save data to Excel files and customize or filter the output. KendoReact Excel Export package
422 lines (400 loc) • 14.3 kB
text/typescript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { AggregateResult } from '@progress/kendo-data-query';
import { default as default_2 } from 'prop-types';
import { GroupResult } from '@progress/kendo-data-query';
import { JSX } from 'react/jsx-runtime';
import * as KendoOoxml from '@progress/kendo-ooxml';
import * as React_2 from 'react';
import { WorkbookOptions } from '@progress/kendo-ooxml';
import { WorkbookSheetRowCellBorderBottom } from '@progress/kendo-ooxml';
import { WorkbookSheetRowCellBorderLeft } from '@progress/kendo-ooxml';
import { WorkbookSheetRowCellBorderRight } from '@progress/kendo-ooxml';
import { WorkbookSheetRowCellBorderTop } from '@progress/kendo-ooxml';
/**
* The options for the Excel Export cell.
*/
export declare interface CellOptions {
/**
* Sets the background color of the cell. Supports hex CSS-like values that start with `"#"`. For example, `"#ff00ff"`.
*/
background?: string;
/**
* The style information for the bottom border of the cell.
*/
borderBottom?: WorkbookSheetRowCellBorderBottom;
/**
* The style information for the left border of the cell.
*/
borderLeft?: WorkbookSheetRowCellBorderLeft;
/**
* The style information for the top border of the cell.
*/
borderTop?: WorkbookSheetRowCellBorderTop;
/**
* The style information for the right border of the cell.
*/
borderRight?: WorkbookSheetRowCellBorderRight;
/**
* If set to `true`, renders the cell value in bold.
*/
bold?: boolean;
/**
* The text color of the cell. Supports hex CSS-like values that start with `"#"`. For example, `"#ff00ff"`.
*/
color?: string;
/**
* Sets the font that is used to display the cell value.
*/
fontFamily?: string;
/**
* Sets the font size in pixels.
*/
fontSize?: number;
/**
* Sets the format that Excel uses to display the cell value. For more information, refer to the page on [supported Excel formats](https://support.office.com/en-us/article/Create-or-delete-a-custom-number-format-78f2a361-936b-4c03-8772-09fab54be7f4).
*/
format?: string;
/**
* If set to `true`, renders the cell value in italics.
*/
italic?: boolean;
/**
* Sets the horizontal alignment of the cell value.
*
* The supported values are:
* * `"left"`
* * `"center"`
* * `"right"`
*/
textAlign?: 'left' | 'center' | 'right';
/**
* If set to `true`, underlines the cell value.
*/
underline?: boolean;
/**
* If set to `true`, wraps the cell value.
*/
wrap?: boolean;
/**
* Sets the vertical alignment of the cell value.
*
* The supported values are:
* * `"top"`
* * `"center"`
* * `"bottom"`
*/
verticalAlign?: 'top' | 'center' | 'bottom';
}
/**
* @hidden
*/
export declare interface ColumnBase {
/**
* @hidden
*/
children?: any;
/**
* The options of the column header cell.
*/
headerCellOptions?: CellOptions;
/**
* Sets the visibility of the column.
*
* @default false
*/
hidden?: boolean;
/**
* @hidden
*/
level?: number;
/**
* Toggles the locked (frozen) state of the column.
*
* @default false
*/
locked?: boolean;
/**
* The title of the column.
*/
title?: string;
/**
* The width of the column in pixels.
*/
width?: number;
}
/**
* Represents the KendoReact ExcelExport component.
*
* @remarks
* Supported children components are: {@link ExcelExportColumn}.
*/
export declare class ExcelExport extends React_2.Component<ExcelExportProps> {
/**
* @hidden
*/
static propTypes: {
children: default_2.Requireable<any>;
columns: default_2.Requireable<any[]>;
creator: default_2.Requireable<string>;
data: default_2.Requireable<any>;
date: default_2.Requireable<any>;
filterable: default_2.Requireable<boolean>;
fileName: default_2.Requireable<string>;
forceProxy: default_2.Requireable<boolean>;
group: default_2.Requireable<any>;
headerPaddingCellOptions: default_2.Requireable<any>;
paddingCellOptions: default_2.Requireable<any>;
proxyURL: default_2.Requireable<string>;
dir: default_2.Requireable<string>;
hierarchy: default_2.Requireable<boolean>;
collapsible: default_2.Requireable<boolean>;
};
/**
* @hidden
*/
static defaultProps: {
fileName: string;
forceProxy: boolean;
collapsible: boolean;
};
private readonly showLicenseWatermark;
constructor(props: ExcelExportProps);
/**
* Saves the data to Excel.
*
* @param exportData - An optional parameter. Can be the data that will be exported or the [`WorkbookOptions`]({% slug api_excel-export_kendoooxml %}#toc-workbookoptions).
* @param columns - An optional parameter. If present, it will be used instead of the columns prop or the child column components.
*/
save(exportData?: any[] | ExcelExportData | WorkbookOptions, columns?: ExcelExportColumnProps[] | React_2.ReactElement<ExcelExportColumnProps>[]): void;
/**
* Returns a promise which will be resolved with the file data URI.
*
* @param exportData - The optional data or the [`WorkbookOptions`]({% slug api_excel-export_kendoooxml %}#toc-workbookoptions) that will be used to generate the data URI.
* @param externalColumns - The optional columns that will be used.
* @returns {Promise<string>} - The promise that will be resolved by the file data URI.
*/
toDataURL(exportData?: any[] | ExcelExportData | WorkbookOptions, columns?: any[]): Promise<string>;
/**
* Based on the specified columns and data, returns [`WorkbookOptions`]({% slug api_excel-export_kendoooxml %}#toc-workbookoptions).
*
* @param exportData - The optional data that will be exported.
* @param externalColumns - The optional columns that will be used.
* @returns {WorkbookOptions} - The workbook options.
*/
workbookOptions(exportData?: any[] | ExcelExportData, externalColumns?: ExcelExportColumnProps[] | React_2.ReactElement<ExcelExportColumnProps>[]): WorkbookOptions;
/**
* @hidden
*/
render(): JSX.Element;
protected saveFile: (dataURL: string) => void;
private extractColumns;
private extractChild;
private getExportData;
}
/**
* Represents the columns of the KendoReact ExcelExport component.
*
* @returns null
*/
export declare const ExcelExportColumn: React_2.FunctionComponent<ExcelExportColumnProps>;
/**
* Represents the column group component of the KendoReact ExcelExport component.
*
* @returns null
*/
export declare const ExcelExportColumnGroup: React_2.FunctionComponent<ExcelExportColumnGroupProps>;
export declare interface ExcelExportColumnGroupProps extends ColumnBase {
}
/**
* Represents the props of the KendoReact ExcelExportColumnProps component.
*/
export declare interface ExcelExportColumnProps extends ColumnBase {
/**
* The options of the column data cells.
*/
cellOptions?: CellOptions;
/**
* The field to which the column is bound.
*/
field?: string;
/**
* The options of the column footer cell.
*/
footerCellOptions?: CellOptions;
/**
* The column footer. Can be a function or a React component.
*/
footer?: Function | ExcelExportFooter;
/**
* The options of the column group footer cells.
*/
groupFooterCellOptions?: CellOptions;
/**
* The footer of the group. Can be a function or a React component.
*/
groupFooter?: Function | ExcelExportGroupFooter;
/**
* The options of the column group header cells.
*/
groupHeaderCellOptions?: CellOptions;
/**
* The header of the group. Can be a function or a React component.
*/
groupHeader?: Function | ExcelExportGroupHeader;
}
/**
* The type that is expected for the ExcelExportComponent data.
*/
export declare interface ExcelExportData {
/**
* The exported data. If grouped, the data must be structured as described in the [`GroupResult`]({% slug api_kendo-data-query_groupresult %}) of the KendoReact Data Query component.
*/
data?: any[];
/**
* The exported data groups. The groups must be compatible with the [`GroupDescriptor`]({% slug api_kendo-data-query_groupdescriptor %}) of the KendoReact Data Query component.
*/
group?: any[];
}
/**
* Represents the return type of ExcelExportExportEvent.
*/
export declare type ExcelExportExportEvent = {
/**
* The target of the ExcelExportExportEvent from ExcelExport.
*/
target: ExcelExport;
};
/**
* Represents the footer of column.
*/
export declare class ExcelExportFooter extends React_2.PureComponent<ExcelExportFooterProps> {
}
/**
* Represents the props that will be passed to the ExcelExportFooter component when the template is rendered.
*/
export declare interface ExcelExportFooterProps {
column: ExcelExportColumnProps;
columnIndex: number;
}
/**
* Represents the footer of the column group.
*/
export declare class ExcelExportGroupFooter extends React_2.PureComponent<ExcelExportGroupFooterProps> {
}
/**
* Represents the props that will be passed to the ExcelExportGroupFooter component when the template is rendered.
*/
export declare interface ExcelExportGroupFooterProps {
field: string;
column: ExcelExportColumnProps;
aggregates: AggregateResult;
group: GroupResult;
}
/**
* Represents the header of the column group.
*/
export declare class ExcelExportGroupHeader extends React_2.PureComponent<ExcelExportGroupHeaderProps> {
}
/**
* Represents the props that will be passed to the ExcelExportGroupHeader component when the template is rendered.
*/
export declare interface ExcelExportGroupHeaderProps {
field: string;
aggregates: AggregateResult;
group: GroupResult;
value: any;
}
/**
* Represents the props of the KendoReact ExcelExport component.
*/
export declare interface ExcelExportProps {
/**
* @hidden
*/
children?: any;
/**
* You can pass the columns through the props of the component. If both the columns prop and the child column components are presented, the columns from props will be used.
*/
columns?: ExcelExportColumnProps[];
/**
* The creator of the workbook.
*/
creator?: string;
/**
* The exported data. If grouped, the data must be structured as described by the [`GroupResult`]({% slug api_kendo-data-query_groupresult %}) option of the KendoReact Data Query component.
*/
data?: any[];
/**
* The date on which the workbook is created. The default value is `new Date()`.
*/
date?: Date;
/**
* Enables or disables the column filtering in the Excel file.
*/
filterable?: boolean;
/**
* Specifies the name of the file that is exported to Excel. Defaults to `Export.xlsx`.
*/
fileName?: string;
/**
* If set to `true`, the content is forwarded to `proxyURL` even if the browser supports the saving of files locally.
*/
forceProxy?: boolean;
/**
* The exported data groups. The groups must be compatible with the [`GroupDescriptor`]({% slug api_kendo-data-query_groupdescriptor %}) option of the KendoReact Data Query component.
*/
group?: any[];
/**
* The options of the cells that are inserted before the header cells to align the headers and the column values (when the data is grouped).
*/
headerPaddingCellOptions?: CellOptions;
/**
* The options of the cells that are inserted before the data, group, and footer cells to indicate the group hierarchy (when the data is grouped).
*/
paddingCellOptions?: CellOptions;
/**
* The URL of the server-side proxy which will stream the file to the end user. When the browser is not capable of saving files locally—for example, Internet Explorer 9 and earlier, and Safari—a proxy is used. The implementation of the server-side proxy has to be done by you.
*
* The proxy receives a `POST` request with the following parameters in the request body:
* - `contentType`—The MIME type of the file.
* - `base64`—The base-64 encoded file content.
* - `fileName`—The file name, as requested by the caller. The proxy is expected to return the decoded file with the **Content-Disposition** header set to `attachment; filename="<fileName.xslx>"`.
*/
proxyURL?: string;
/**
* If set to `rtl`, the Excel file will be rendered in the right-to-left mode.
*/
dir?: string;
/**
* If set to true the data will be exported as a tree based on the `level` property of each data record.
*/
hierarchy?: boolean;
/**
* Enables or disables collapsible (grouped) rows in the exported file.
*/
collapsible?: boolean;
/**
* Triggered after the export is complete.
*/
onExportComplete?: (event: ExcelExportExportEvent) => void;
}
/**
* @hidden
*/
export declare const isWorkbookOptions: (value: any) => boolean;
export { KendoOoxml }
/**
* @hidden
*/
export declare const toDataURL: (options: WorkbookOptions) => Promise<string>;
/**
* @hidden
*/
export declare const workbookOptions: (options: ExcelExportProps) => WorkbookOptions;
export { }