Back to Devexpress

TdxCustomDashboardControl.ExportToXLSX(TStream) Method

vcl-dxdashboard-dot-control-dot-tdxcustomdashboardcontrol-dot-exporttoxlsx-x28-system-dot-classes-dot-tstream-x29.md

latest5.2 KB
Original Source

TdxCustomDashboardControl.ExportToXLSX(TStream) Method

Exports dashboard content to a stream in the Office OpenXML Spreadsheet Format (XLSX).

Declaration

delphi
procedure ExportToXLSX(AStream: TStream);

Parameters

NameTypeDescription
AStreamTStream

The target stream.

|

Remarks

Call the ExportToXLSX procedure to export dashboard content to a stream in the XLSX format.

Code Example: Export Dashboard Content to an XLSX File

The following code example exports content of a configured TdxDashboardControl component to a file in the XLSX format using an intermediary TMemoryStream object:

delphi
uses
  dxDashboard.Control, // Declares the TdxDashboardControl component
  dxShellDialogs; // Declares the TdxSaveFileDialog component
// ...

procedure TMyForm.cxButtonExportToXLSXClick(Sender: TObject);
var
  AStream: TMemoryStream;
begin
  if not dxSaveFileDialog1.Execute(Handle) then Exit; // Displays the "Save File" dialog
  AStream := TMemoryStream.Create; // Creates a stream as an intermediary container
  try
    dxDashboardControl1.ExportToXLSX(AStream); // Exports content to a stream in the XLSX format
    AStream.SaveToFile(dxSaveFileDialog1.FileName); // Saves XLSX stream content to a file
  finally
    AStream.Free; // Releases the intermediary memory stream
  end;
end;
cpp
#include "dxDashboard.Control.hpp" // Declares the TdxDashboardControl component
#include "dxShellDialogs.hpp" // Declares the TdxSaveFileDialog component

// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxDashboard.Control" // Required to use dxDashboard.Control.hpp declarations
#pragma link "dxShellDialogs" // Required to use dxShellDialogs.hpp declarations
// ...

void __fastcall TMyForm::cxButtonExportToXLSXClick(TObject *Sender)
{
  if(!dxSaveFileDialog1->Execute(Handle)) { return; } // Displays the "Save File" dialog
  TMemoryStream *AStream = new TMemoryStream(); // Creates a stream as an intermediary container
  try
  {
    dxDashboardControl1->ExportToXLSX(Handle); // Exports content to a stream in the XLSX format
    AStream->SaveToFile(dxSaveFileDialog1->FileName); // Saves XLSX stream content to a file
  }
  __finally
  {
    delete AStream; // Releases the intermediary memory stream
  }
}

To see the dashboard export functionality in action, run the BI Dashboards Designer/Viewer demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Select any demo in the sidebar on the left, click the Export button, and use any export option listed in the menu.

Download: Compiled VCL Demos

Tip

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

_%PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressDashboards_

Other Export Methods

You can call the following procedures to export dashboard content to a stream in other formats:

ExportToExports dashboard content to a stream in any supported format.ExportToCSVExports dashboard content to a stream in the comma-separated values (CSV) format.ExportToGIFExports dashboard content to a stream in the Graphics Interchange Format (GIF).ExportToJPGExports dashboard content in the JPEG format.ExportToPDFExports dashboard content to a stream in the Portable Document Format (PDF).ExportToPNGExports dashboard content to a stream in the Portable Network Graphics (PNG) format.ExportToSVGExports dashboard content to a stream in the Scalable Vector Graphics (SVG) format.ExportToXLSExports dashboard content to a stream in the Microsoft Excel® binary format (XLS). See Also

TdxDashboard.ExportTo Procedure

TdxReport.ExportToXLSX Procedure

TdxCustomDashboardControl Class

TdxCustomDashboardControl Members

dxDashboard.Control Unit