Adsense

miércoles, 25 de junio de 2008

Export cxGrid (QuantumGrid) to Excel

Debe estar la unidad

cxGridExportLink

se lama el procedimiento:

procedure ExportGridToExcel(const AFileName: string; AGrid: TcxGrid; AExpand: Boolean = True; ASaveAll: Boolean = True; AUseNativeFormat: Boolean = True; const AFileExt: string = ‘xls’);

Y listo. a continuación lo que dice la ayuda:

Description

Use the ExportGridToExcel method to export the grid control’s content into an XLS file. The target file’s name is specified by the AFileName parameter. Note that you should not specify the file’s extension using this parameter. The extension will be automatically replaced with the AFileExt parameter value.

The grid control whose content is to be copied is specified by the AGrid parameter. Note that only the currently active root level’s content will be exported. Excel export doesn’t support master-detail data.

The AExpand parameter indicates whether to export all records displayed within the exported level including records hidden within collapsed groups. If this parameter value is True, the grid expands all group and master records before exporting. If this parameter value is False, the records’ expanded state remains unchanged and only visible records’ content is written to the file.

The ASaveAll parameter indicates whether to export all or selected records. Set the parameter to False to export only the current selection. In grid mode, this parameter value is ignored and all records are exported.

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
TcxMaskEditProperties or TcxCalcEditProperties Currency, if the editor is bound to the field whose values are formatted as currency values (see the field’s Currency property).Otherwise, Number.
TcxDateEdit Date
TcxTimeEdit Time
TcxSpinEdit Number
Note: if columns don’t use editors listed above, values from that columns are exported as strings regardless of the AUseNativeFormat parameter value. If a particular cell’s text cannot be converted to the required format (if the cell contains invalid characters, for instance) or the data type of an underlying data field does not exactly correspond to the data type associated with the assigned editor (for instance, a numeric data field used to store currency values), it is exported as a string.

If the AUseNativeFormat parameter value is False, all values are exported as strings.

No hay comentarios: