vcl-dxchartcontrol-dot-tdxcustomchartcontrol-dot-exporttoxlsx-x28-system-dot-string-system-dot-integer-system-dot-integer-x29.md
Exports content as an image container within an XLSX (Office OpenXML Spreadsheet) document and saves it to a file.
procedure ExportToXLSX(const AFileName: string; AImageWidth: Integer = 0; AImageHeight: Integer = 0); overload;
| Name | Type | Description |
|---|---|---|
| AFileName | string |
The absolute or relative path to the resulting XLSX file.
| | AImageWidth | Integer |
Optional. The width (in pixels) of the chart image inserted into the resulting XLSX document. If this parameter is omitted, the pixel width of the resulting image container in the created spreadsheet document matches the current pixel width of the Chart control client area on the parent form.
The export procedure stretches or shrinks the Chart control layout horizontally to fit the resulting image in a spreadsheet into the target width.
All font sizes remain unchanged. If title or label text does not fit into the corresponding visual Chart element, the Chart control crops the text and ends it with an ellipsis in the exported layout.
| | AImageHeight | Integer |
Optional. The height (in pixels) of the chart image inserted into the resulting XLSX document. If this parameter is omitted, the pixel height of the resulting image container in the created spreadsheet document matches the current pixel height of the Chart control client area on the parent form.
All font sizes remain unchanged. If title or label text does not fit into the corresponding visual Chart element, the Chart control crops the text and ends it with an ellipsis in the exported layout.
|
Call the ExportToXLSX procedure to save content of the Chart control client area as a floating image container in an XLSX file. The resulting image size matches the actual pixel dimensions of the Chart control client area on a form.
The following image demonstrates an XLSX document with exported chart content opened in a VCL SpreadSheet-based application:
You can pass required target pixel dimensions for the resulting image as optional AImageWidth and AImageHeight parameters. In this case, the ExportToXLSX procedure resizes all visible diagrams to fit into the target dimensions. All font sizes remain unchanged.
The following code example exports shrunk content of the Chart control client area (original dimensions on the parent form are 600 by 700 pixels):
begin
dxSavePictureDialog1.Execute(Handle);
if dxSavePictureDialog1.FileName = '' then Exit;
dxChartControl1.ExportToXLSX(dxSavePictureDialog1.FileName, 315, 385);
end;
// ...
dxSavePictureDialog1->Execute(Handle);
if(dxSavePictureDialog1->FileName == "") { return; }
dxChartControl1->ExportToXLSX(dxSavePictureDialog1->FileName, 315, 385);
To see the export to XLSX functionality in action, run the Chart Control demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Click Export and choose the Export to XLSX option to export chart content in the XLSX (Office OpenXML Spreadsheet) format.
Tip
Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users ( default ). You can find all project and source code files for the Chart control in the following folder:
_%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressChart_
You can call the following procedures to export chart content to a file or stream in other formats:
ExportToImageExport the current state of the Chart control client area as an individual image in any supported format.ExportToBMP | ExportToGIF | ExportToJPEG | ExportToPNG | ExportToSVG | ExportToTIFFExport the current state of the Chart control client area as an individual image in corresponding formats.ExportToDOCXExports the current state of the Chart control client area as an inline or floating image in the resulting DOCX (Office OpenXML) document.ExportToEMF | ExportToWMFExport the current state of the Chart control client area as an individual image in Windows Metafile (EMF and WMF) formats. See Also
TdxCustomChartControl.ExportToXLSX(System.Classes.TStream,System.Integer,System.Integer) Procedure
TdxCustomChartControl.ExportToDOCX(System.Classes.TStream,System.Integer,System.Integer) Procedure
TdxCustomChartControl.ExportToDOCX(System.String,System.Integer,System.Integer) Procedure