TdxCustomSpreadSheet.LoadFromStream(TStream,TdxSpreadSheetCustomFormatClass) Method
Loads a spreadsheet document from a stream.
Declaration
procedure LoadFromStream(AStream: TStream; AFormat: TdxSpreadSheetCustomFormatClass); overload; virtual;
Parameters
| Name | Type | Description |
|---|---|---|
| AStream | TStream | The source stream. |
| AFormat | TdxSpreadSheetCustomFormatClass | The required spreadsheet document format for the source stream ( The specified format must match the actual document format within the source stream. Otherwise, an error occurs. Refer to the following section for a complete list of available options: Available Import Formats. |
Remarks
Call the LoadFromStream procedure to import a spreadsheet document from a stream in any supported format.
Available Import Formats
- TdxSpreadSheetBinaryFormat
- Internal Spreadsheet control binary format.
- TdxSpreadSheetCSVFormat
- Comma-Separated Values (CSV) format.
- TdxSpreadsheetODSFormat
- Open Document Spreadsheet (ODS) format.
- TdxSpreadSheetXLSFormat | TdxSpreadSheetXLTFormat
- Microsoft Excel® Binary Format (XLS/XLT).
- TdxSpreadSheetXLSXFormat | TdxSpreadSheetXLTXFormat
- Office OpenXML Spreadsheet Format (XLSX/XLTX).
Code Example: Copy XLSX Documents Between Spreadsheet Controls
The following code example copies a document between two TdxSpreadSheet control instances (from dxSpreadSheet1 to dxSpreadSheet2) using an intermediary memory stream in the Office OpenXML Spreadsheet (XLSX) format:
uses
dxSpreadSheet, // Declares the TdxSpreadSheet control
dxSplashForms; // Declares the TdxSplashFormManager class and related types
// ...
procedure TMyForm.cxButtonExportToXLSXClick(Sender: TObject);
var
AStream: TMemoryStream;
begin
AStream := TMemoryStream.Create; // Creates a stream as an intermediary container
// Displays a Wait Form before export and import operations
TdxSplashFormManager.WaitForm.Show(dxSpreadSheet1.Parent);
try
dxSpreadSheet1.SaveToStream(AStream, TdxSpreadSheetXLSXFormat); // Exports content
AStream.Position := 0; // Resets stream position
dxSpreadSheet2.LoadFromStream(AStream, TdxSpreadSheetXLSXFormat); // Imports content
finally
AStream.Free; // Releases the intermediary memory stream
TdxSplashFormManager.WaitForm.Hide; // Hides the Wait Form once operations are complete
end;
end;
See Also