IPrxReport.SaveToStream

Fore Syntax

SaveToStream(Stream: IIOStream; Mode: PrxReportSaveMode);

Fore.NET Syntax

SaveToStream(Stream: System.IO.Stream; Mode: Prognoz.Platform.Interop.Report.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.

Fore 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.

Fore.NET 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.

Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Marshalers;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;

Private Sub UserProc();
Var
    MB: IMetabase;
    TableInst: IDatasetInstance;
    Cache: ICachedDataset;
    Fields: IDatasetInstanceFields;
    Report: IPrxReport;
    IOStreamMarsh: ForeIOStreamMarshaler = New ForeIOStreamMarshaler();
    RepStream: System.IO.MemoryStream = New System.IO.MemoryStream();
Begin
    MB := Self.Metabase;
    //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;
    //Save regular report to stream
    Report.SaveToStream(RepStream, PrxReportSaveMode.prsmFull);
    //Saving stream contents to table
    Fields.FindById("REPORT").Value := IOStreamMarsh.ManagedToFore(RepStream);
    Cache.Post();
    RepStream := Null;
End Sub;

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