找到了,谢谢!
Unit
cxExportGrid4Link
Declaration
procedure ExportGrid4ToExcel(const AFileName: string; AGrid: TcxGrid; AExpand: Boolean = True; ASaveAll: Boolean = True; AUseNativeFormat: Boolean = False);
Description
The ExportGrid4ToExcel method exports records from the AGrid control in MS Excel format. Note: ExportGrid4ToExcel is restricted to grids with a single level, i.e. it does not support exporting detail views. Detail views are ignored.
The AFileName parameter defines the name and the path of the output XLS file. Any extension specified in this parameter is replaced with ‘.xls’.
The AExpand parameter indicates whether to export all records displayed in the grid including those hidden within collapsed groups. If this parameter value is False, only visible records are written to the file.
The ASaveAll parameter indicates whether to export selected or all records.
If the AUseNativeFormat parameter is True, the export routine tries to convert display text of grid cells to the corresponding Excel format (Currency, Date, Time or Float). If you specify an editor to an item, the display text of all cells in the item is converted to a proper MS Excel format according to the following table:
An editor assigned to a grid cell The corresponding MS Excel format
TcxCurrencyEdit Currency
TcxDateEdit Date
TcxTimeEdit Time
TcxCalcEdit or TcxSpinEdit Float
If the text of a specific cell cannot be converted to a required format (if the cell contains invalid characters), it is exported as a string.
If an item is assigned an editor of a type not listed in the table above, the export routine still tries to convert individual cells in turn to the Currency, Date, Time and Float formats using the system’s regional settings. If the conversion to all of these formats fails, the cell’s text is exported as a string.
Refer to the Items section for more information on assigning editors to items in EQGrid4.
If AUseNativeFormat is set to False, display text of all cells is exported as strings without conversion.
The following image shows data exported to MS Excel format: