Skip to main content
All docs
V25.1
  • TdxCustomChartControl.ExportToXLSX(TStream,Integer,Integer) Method

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

    Declaration

    procedure ExportToXLSX(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 XLSX document saved to the target stream (AStream). 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.

    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 saved to the target stream (AStream). 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.

    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 ExportToXLSX procedure to save content of the Chart control client area as a floating image container in an XLSX document created in the target stream. The resulting image size matches the actual pixel dimensions of the Chart control client area on a form.

    Exported Content Example

    The following image demonstrates an XLSX document with exported chart content opened in a VCL SpreadSheet-based application:

    VCL Chart Control: Exported Chart Content in a Spreadsheet XLSX Document

    Adjust Target Image Dimensions

    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.

    Code Example: Export Chart Content as XLSX

    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.ExportToXLSX(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 spreadsheet 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 XLSX item.

    Download: Compiled VCL Demos

    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

    See Also