Skip to main content

TdxCustomChartControl.ExportToDOCX(TStream,Integer,Integer) Method

Exports content as an image container in a DOCX document and saves it to the target stream.

Declaration

procedure ExportToDOCX(const AStream: TStream; AImageWidth: Integer = 0; AImageHeight: Integer = 0); overload;

Parameters

Name Type Description
AStream TStream

The target stream.

AImageWidth Integer

Optional. The width (in pixels) of the chart image inserted into the resulting DOCX document. If this parameter is omitted, the pixel width of the resulting image container in the created 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 document into the target width. If target image dimensions exceed the document page width, the export procedure proportionally shrinks the image to fit it into the page.

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 DOCX document. If this parameter is omitted, the pixel height of the resulting image container in the created document matches the current pixel height of the Chart control client area on the parent form.

The export procedure stretches or shrinks the Chart control layout vertically to fit the resulting image in a document into the target height. If target image dimensions exceed the document page height, the export procedure proportionally shrinks the image to fit it into the page.

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.

Remarks

Call the ExportToDOCX procedure to save content of the Chart control client area as an inline image container in a DOCX document created in the target stream. The resulting image size matches the actual pixel dimensions of the Chart control client area on a form.

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

Exported Content Example

The following image demonstrates a DOCX document with exported chart content opened in a VCL Rich Edit Control-based application:

VCL Chart Control: Exported Chart Content in a DOCX Document

Code Example

The following code example exports shrunk content of the Chart control client area whose original dimensions on the parent form are 600 by 700 pixels:

var
  AStream: TMemoryStream;
begin
  dxSavePictureDialog1.Execute(Handle);
  if dxSavePictureDialog1.FileName = '' then Exit;
  AStream := TMemoryStream.Create;
  try
    dxChartControl1.ExportToDOCX(AStream, 315, 385);
    AStream.SaveToFile(dxSavePictureDialog1.FileName);
  finally
    AStream.Free;
  end;
end;

VCL Chart Control: An Exported Shrunk Chart Content Example

To see the export to document functionality in action, run the Chart Control demo in the VCL Demo Center installed with compiled VCL DevExpress demos. Click Export and choose the Export to DOCX item.

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

See Also