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 REG_REPORT_TMP identifier.
Add links to the Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Sheets: IPrxSheets;
Sheet: IPrxSheet;
SheetDoc: IPrxDocument;
SheetTab: IPrxTable;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get report
Report := Mb.ItemById("PROC_REPORT_TMP").Edit As IPrxReport;
// Get report sheets
Sheets := Report.Sheets;
Sheets.Clear;
// Add table sheet
Sheet := Sheets.Add("Table1");
Debug.WriteLine("Table sheet is added " + Sheet.Name + ";");
// Enter value to table sheet
SheetTab := Sheet As IPrxTable;
SheetTab.TabSheet.Cell(5, 5).Value := 1;
// Add text sheet
Sheet := Sheets.Add("Doc4", PrxSheetType.Document);
Debug.WriteLine("Text sheet is added " + Sheet.Name + ";");
// Enter value to text sheet
SheetDoc := Sheet As IPrxDocument;
SheetDoc.RichText := "{\rtf1 Text sheet}";
// Insert table sheet
Sheet := Sheets.Insert(1, "Table2");
Debug.WriteLine("Table sheet is inserted " + Sheet.Name + ";");
// Insert text sheet
Sheet := Sheets.InsertAfter(1, "Doc3", PrxSheetType.Document);
Debug.WriteLine("Text sheet is inserted " + Sheet.Name + ".");
// Save report
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a table and a text sheet are inserted to the report, a table and a text sheet are inserted, the 1 value is entered to the Table1 table sheet, the Text Sheet text sheet is added to the Doc4 text sheet, the console window displays the appropriate information about added and inserted sheets.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Report;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Sheets: IPrxSheets;
SheetDoc: IPrxDocument;
SheetTab: IPrxTable;
Sheet: IPrxSheet;
Begin
// Get current repository
MB := Params.Metabase;
// Get report
Report := Mb.ItemById["PROC_REPORT_TMP"].Edit() As IPrxReport;
// Get report sheets
Sheets := Report.Sheets;
Sheets.Clear();
// Add table sheet
Sheet := Sheets.Add("Table1", 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 := 1;
// Add text sheet
Sheet := Sheets.Add("Doc4", 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}";
// Insert table sheet
Sheet := Sheets.Insert(1, "Table2", PrxSheetType.pstTable);
System.Diagnostics.Debug.WriteLine("Table sheet is inserted " + Sheet.Name + ";");
// Insert text sheet
Sheet := Sheets.InsertAfter(1, "Doc3", PrxSheetType.pstDocument);
System.Diagnostics.Debug.WriteLine("Text sheet is inserted " + Sheet.Name + ".");
// Save report
(Report As IMetabaseObject).Save();
End Sub;
See also: