TdxDashboard.ExportToCSV(TStream) Method
Exports dashboard content to a stream in the comma-separated values (CSV) format.
Declaration
procedure ExportToCSV(AStream: TStream); overload;
Parameters
| Name | Type | Description |
|---|---|---|
| AStream | TStream | The target stream. |
Remarks
Call the ExportToCSV procedure to export dashboard content to a stream in the CSV format.
In this topic…
Code Example: Export Dashboard Content to CSV File Without User Interaction
The following code example configures a memory-based data source (TdxBackendInMemoryJSONConnection), loads an XML dashboard layout, and exports dashboard content to a CSV file without user interaction:
uses
dxBackend.ConnectionString.JSON, // Declares the TdxBackendInMemoryJSONConnection component
dxDashboard; // Declares the TdxDashboard class
// ...
procedure TMyForm.cxExportButtonClick(Sender: TObject);
var
ADashboard: TdxDashboard;
AJSONDataConnection: TdxBackendInMemoryJSONConnection;
AMemoryStream: TMemoryStream;
AJSONData: string;
begin
// Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows:
AJSONData :=
'[{"id": 1, "Region": "Asia", "Sales": 4.7685},' + // Row #1
'{"id": 2, "Region": "Australia", "Sales": 1.9576},' + // Row #2
'{"id": 3, "Region": "Europe", "Sales": 3.3579},' + // Row #3
'{"id": 4, "Region": "North America", "Sales": 3.7477},' + // Row #4
'{"id": 5, "Region": "South America", "Sales": 1.8237}]'; // Row #5
AJSONDataConnection := TdxBackendInMemoryJSONConnection.Create(Self); // Creates a data connection
try
AJSONDataConnection.Name := 'JSONData'; // Assigns a name to the created data connection
AJSONDataConnection.SetJSONValue(AJSONData); // Assigns the defined JSON data string
ADashboard := TdxDashboard.Create(Self); // Creates a TdxDashboard container
try
ADashboard.Layout.LoadFromFile('MyDashboardLayout.xml'); // Loads an XML dashboard layout
ADashboard.Name := 'MyDashboard'; // Defines a dashboard name
AMemoryStream := TMemoryStream.Create; // Creates a memory stream
try
// Export dashboard content to the created memory stream in the CSV format
ADashboard.ExportToCSV(AMemoryStream);
AMemoryStream.SaveToFile(ADashboard.Name + '.csv'); // Saves the resulting CSV file
finally
AMemoryStream.Free; // Releases the memory stream
end;
finally
ADashboard.Free; // Releases the TdxDashboard container
end;
finally
AJSONDataConnection.Free; // Releases the data connection
end;
end;
Other Export Methods
Export to File
- ExportTo
- Exports dashboard content to a stream in any supported format.
- ExportToCSV
- Exports dashboard content to a file in the comma-separated values (CSV) format.
- ExportToGIF
- Exports dashboard content to a file in the Graphics Interchange Format (GIF).
- ExportToJPG
- Exports dashboard content to a file in the Joint Photographic Experts Group (JPEG/JPG) format.
- ExportToPDF
- Exports dashboard content to a file in the Portable Document Format (PDF).
- ExportToPNG
- Exports dashboard content to a file in the Portable Network Graphics (PNG) format.
- ExportToSVG
- Exports dashboard content to a file in the Scalable Vector Graphics (SVG) format.
- ExportToXLS
- Exports dashboard content to a file in the Microsoft Excel® binary format (XLS).
- ExportToXLSX
- Exports dashboard content to a file in the Office OpenXML Spreadsheet Format (XLSX).
Export to Stream
- ExportTo
- Exports dashboard content to a stream in any supported format.
- ExportToGIF
- Exports dashboard content to a stream in the Graphics Interchange Format (GIF).
- ExportToJPG
- Exports dashboard content to a stream in the Joint Photographic Experts Group (JPEG/JPG) format.
- ExportToPDF
- Exports dashboard content to a stream in the Portable Document Format (PDF).
- ExportToPNG
- Exports dashboard content to a stream in the Portable Network Graphics (PNG) format.
- ExportToSVG
- Exports dashboard content to a stream in the Scalable Vector Graphics (SVG) format.
- ExportToXLS
- Exports dashboard content to a stream in the Microsoft Excel® binary format (XLS).
- ExportToXLSX
- Exports dashboard content to a stream in the Office OpenXML Spreadsheet Format (XLSX).
See Also