Add(Name: String, [Type: PrxSheetType = 1]): IPrxSheet;
Add(Name: string; Type: Prognoz.Platform.Interop.Report.PrxSheetType): Prognoz.Platform.Interop.Report.IPrxSheet;
Name. New sheet name.
Type. The type of added sheet, a table sheet is added by default.
The Add method adds a sheet into the regular report.
If the Type parameter value is PrxSheetType.Table, the sheet returned by the Add method can be cast to the IPrxTable interface, if it is PrxSheetType.Document, it can be cast to the IPrxDocument interface.
Executing the example requires that the repository contains a regular report with the REPORT identifier.
Add links to the Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Sheets: IPrxSheets;
Sheet: IPrxSheet;
SheetDoc: IPrxDocument;
SheetTab: IPrxTable;
i: Integer;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get report
Report := Mb.ItemById("REPORT").Edit As IPrxReport;
// Get report sheets
Sheets := Report.Sheets;
i := Sheets.Count;
// Add table sheet
Sheet := Sheets.Add("Table" + (i).ToString, PrxSheetType.Table);
Debug.WriteLine("Table sheet is added " + Sheet.Name + ";");
// Enter value to table sheet
SheetTab := Sheet As IPrxTable;
SheetTab.TabSheet.Cell(5, 5).Value := (i);
// Add text sheet
Sheet := Sheets.Add("Doc" + (i + 1).ToString, PrxSheetType.Document);
Debug.WriteLine("Text sheet is added " + Sheet.Name + ";");
// Enter value to text sheet
SheetDoc := Sheet As IPrxDocument;
SheetDoc.RichText := "{\rtf1 Text sheet}";
// Save report
(Report As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Report;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Sheets: IPrxSheets;
SheetDoc: IPrxDocument;
SheetTab: IPrxTable;
Sheet: IPrxSheet;
i: integer;
Begin
// Get current repository
MB := Params.Metabase;
// Get report
Report := Mb.ItemById["REPORT"].Edit() As IPrxReport;
// Get report sheets
Sheets := Report.Sheets;
i := Sheets.Count;
// Add table sheet
Sheet := Sheets.Add("Table" + (i).ToString(), PrxSheetType.pstTable);
System.Diagnostics.Debug.WriteLine("Table sheet is added " + Sheet.Name + ";");
// Enter value to table sheet
SheetTab := Sheet As IPrxTable;
SheetTab.TabSheet.Cell[5, 5].Value := (i);
// Add text sheet
Sheet := Sheets.Add("Doc" + (i + 1).ToString(), PrxSheetType.pstDocument);
System.Diagnostics.Debug.WriteLine("Text sheet is added " + Sheet.Name + ";");
// Enter value to text sheet
SheetDoc := Sheet As IPrxDocument;
SheetDoc.RichText := "{\rtf1 Text sheet}";
// Save report
(Report As IMetabaseObject).Save();
End Sub;
After executing the example, table and text sheets are added to the report, the value equal to the number in the sheet title is inserted to the table sheet, the Text sheet text is added to the text sheet, the console will display information about sheet addition.
See also: