IPrxReport.SaveToStream

Syntax

SaveToStream(Stream: IIOStream; Mode: PrxReportSaveMode);

Parameters

Stream. The stream, to which the regular report will be saved.

Mode. Report saving mode.

Description

The SaveToStream method saves the regular report to a stream.

Comments

Regular reports can be saved to a stream to exchange the data between reports, or save report to a repository table. A regular report can be saved to a field with the user-defined type. For details about working with custom type fields, see the knowledge base in the Working with Fields That Have Custom Data Type article.

To load a regular report from stream, use the LoadFromStream method.

Example

Executing the example requires that the repository contains a table with the RepTable identifier. String fields with the REP_ID and REP_ID identifiers are created in this table, these fields are intended to store identifier and name respectively. Also, the binary field REPORT is created where regular reports are stored.

The repository must also contain a regular report with the Report_1 identifier.

Sub UserProc;
Var
    MB: IMetabase;
    TableInst: IDatasetInstance;
    Cache: ICachedDataset;
    Fields: IDatasetInstanceFields;
    Report: IPrxReport;
    RepStream: IMemoryStream;
Begin
    MB := MetabaseClass.Active;
    //Table to save regular report
    TableInst := MB.ItemById("RepTable").Open(NullAs IDatasetInstance;
    Cache := TableInst.OpenCached;
    Fields := Cache.Fields;
    //Regular report
    Report := MB.ItemById("Report_1").Bind As IPrxReport;
    Cache.Append;
    Fields.FindById("REP_ID").Value := Report.MetabaseObject.Id;
    Fields.FindById("REP_NAME").Value := Report.MetabaseObject.Name;
    //Stream, to which regular report must be saved
    RepStream := New MemoryStream.Create;
    Report.SaveToStream(RepStream, PrxReportSaveMode.Full);
    //Save stream contents to table
    Fields.FindById("REPORT").Value := RepStream;
    Cache.Post;
    Dispose RepStream;
End Sub UserProc;

On executing the example a new record is created in the table. Information on the regular report and the report itself is saved to the fields. The regular report is saved to a table field via stream.

See also:

IPrxReport