Skip to main content
All docs
V23.2

VCL Chart Data Export

  • 5 minutes to read

The Chart control has a number of data export methods you can use to save content to a file or stream in a format of your choice: BMP, DOCX, EMF, GIF, JPEG, PNG, SVG, TIFF, WMF, and XLSX. All export methods replicate the Chart control’s client area as an image in the target format. If you select a document format (DOCX or XLSX), the corresponding method inserts the generated image into the resulting document as a floating or inline container.

Image Format-Specific Export Methods

The following Chart control methods save content as an individual image in corresponding formats:

Device-Independent Bitmap (BMP/DIB)

ExportToBMP(TStream,Integer,Integer)
Exports content to a stream in BMP (device-independent bitmap) format.
ExportToBMP(string,Integer,Integer)
Exports content to a file in BMP (device-independent bitmap) format.

Graphics Interchange Format (GIF)

ExportToGIF(TStream,Integer,Integer)
Exports content to a stream in GIF format.
ExportToGIF(string,Integer,Integer)
Exports content to a file in GIF format.

Joint Photographic Experts Group (JPEG)

ExportToJPEG(TStream,Integer,Integer)
Exports content to a stream in JPEG format.
ExportToJPEG(string,Integer,Integer)
Exports content to a file in JPEG format.

Portable Network Format (PNG)

ExportToPNG(TStream,Integer,Integer)
Exports content to a stream in PNG (Portable Network Graphics) format.
ExportToPNG(string,Integer,Integer)
Exports content to a file in PNG (Portable Network Graphics) format.

Scalable Vector Graphics (SVG)

ExportToSVG(TStream,Integer,Integer)
Exports content to a stream in SVG (Scalable Vector Graphics) format.
ExportToSVG(string,Integer,Integer)
Exports content to a file in SVG format.

Tagged Image File Format (TIFF)

ExportToTIFF(TStream,Integer,Integer)
Exports content to a stream in TIFF (Tagged Image File Format) format.
ExportToTIFF(string,Integer,Integer)
Exports content to a file in TIFF (Tagged Image File Format) format.

Windows Metafile Formats (WMF and EMF)

Windows Metafile and Enhanced Windows Metafile format implementations rely on the functionality of the native Windows Metafile encoder from the Windows Imaging Component (WIC).

ExportToEMF(TStream,Integer,Integer)
Exports content to a stream in EMF format.
ExportToEMF(string,Integer,Integer)
Exports content to a file in EMF format.
ExportToWMF(TStream,Integer,Integer)
Exports content to a stream in WMF format.
ExportToWMF(string,Integer,Integer)
Exports content to a file in WMF format.

Note

Content export results (including exported image dimensions) may vary significantly depending on the target operating system and its GDI+ library version.

Universal Export Methods

The following Chart control methods allow you to save content in any supported image format:

ExportToImage(string,TdxSmartImageCodecClass,Integer,Integer)

Exports content to a file in any supported image format.

You can pass a reference to a supported codec class as the ACodecClass parameter to specify the target image format. If you omit this parameter, the procedure attempts to identify the target format by the specified file name extension.

ExportToImage(TStream,TdxSmartImageCodecClass,Integer,Integer)

Export content to a stream in any supported image format.

You can pass a reference to a supported codec class as the ACodecClass parameter to specify the target image format. If you omit this parameter, the procedure exports content in SVG format.

Document Formats

DOCX and XLSX export methods work identically to image export methods but they insert a generated Chart bitmap image into the resulting document as a container. The exported document includes no other content.

VCL Chart Control: An Exported Shrunk Chart Content Example

Office Open XML Document (DOCX and DOTX)

A compressed XML-based rich text document format used by Microsoft Word® 2007 and later versions. The following Chart control methods export content as an inline image container in the resulting document:

ExportToDOCX(string,Integer,Integer)
Exports content as an image container in a DOCX document and saves it to a file.
ExportToDOCX(TStream,Integer,Integer)
Exports content as an image container in a DOCX document and saves it to the target stream.

Note

If the resulting image width or height exceeds the document page width or height, the export procedure shrinks the image proportionally to fit it into the page.

Office Open XML Spreadsheet (XLSX and XLTX)

A compressed XML-based spreadsheet document format used by Microsoft Excel® 2007 and later versions. The following Chart control methods export content as a floating image container in the resulting document:

ExportToXLSX(string,Integer,Integer)
Exports content as an image container in an XLSX document and saves it to a file.
ExportToXLSX(TStream,Integer,Integer)
Exports content as an image container in an XLSX document and saves it to the target stream.

To see the content export functionality in action, run the Chart Control demo in the VCL Demo Center installed with compiled VCL DevExpress demos. Click Export and choose any option.

Download: Compiled VCL Demos

Tip

You can find full source code for the installed compiled Chart control demo in the following folder:

%PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressChart

Common Image Export Settings

All export methods save the current state of the Chart control client area as an individual image or an image container in a document. The pixel size of the resulting image, chart layout, and visual element dimensions match the Chart control state on the form; therefore, the result of an export operation depends on the following factors:

  • The Chart control size on a form.
  • The current zoom factors and scroll positions of XY diagrams in the Chart control.
  • The current monitor DPI.

You can pass the required dimensions of the resulting image as optional AImageWidth and AImageHeight parameters of any content export method. These parameter values define custom Chart control dimensions for the purpose of export operations regardless of the current Chart control size in pixels.

Export procedures stretch or shrink the Chart control layout to fit the resulting image to the specified export size. 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.

VCL Chart Control: An Exported Shrunk Chart Content Example

See Also