A regular report contains two data areas:
Data area. An old type of data table with data based on a data slice. It is used only in the Prognoz Platform 9 Reports tool and is calculated only using formulas.
Analytical data area. A new type of data table based on a slice. Opposite the data area, it is used in all tools and is calculated by modeling methods.
See the example of adding a data slice for the data source added before, which the data area is based on.
Executing the example requires that the repository contains a regular report with the REPORT_INTRO identifier.
To execute the example, add links to the Metabase, Report and Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DtSources: IPrxDataSources;
DtSource: IPrxDataSource;
Slices: IPrxSlices;
Slice: IPrxSlice;
DataIsland: IPrxDataIslands;
DI: IPrxDataIsland;
Range: ITabRange;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("REPORT_INTRO").Edit;
Report := MObj As IPrxReport;
// Add a slice:
DtSources := Report.DataSources;
DtSource := DtSources.Item(0);
Slices := DtSource.Slices;
Slice := Slices.Add;
Slice.Execute;
// Add a data area:
DataIsland := Report.DataIslands;
DI := DataIsland.Add;
// Select report sheet:
DI.Sheet := Report.Sheets.Item(0);
// Determine slice which is a source for data area:
DI.Slice := DtSource.Slices.Item(0);
// Determine cell range where data area is located:
Range := Report.ParseCell(DI.Sheet.Name+"!A0").Range;
DI.Range := Range;
MObj.Save;
End Sub UserProc;
After executing the example a slice is added for regular report; a data area will be based on this slice and located on the specified sheet.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;;
Imports Prognoz.Platform.Interop.Tab;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DtSources: IPrxDataSources;
DtSource: IPrxDataSource;
Slices: IPrxSlices;
Slice: IPrxSlice;
DataIsland: IPrxDataIslands;
DI: IPrxDataIsland;
Range: ITabRange;
Begin
MB := Params.Metabase;
MObj := MB.ItemById["REPORT_INTRO"].Edit();
Report := MObj As IPrxReport;
// Add a slice:
DtSources := Report.DataSources;
DtSource := DtSources.Item[0];
Slices := DtSource.Slices;
Slice := Slices.Add();
Slice.Execute();
// Add data area:
DataIsland := Report.DataIslands;
DI := DataIsland.Add();
// Select report sheet:
DI.Sheet := Report.Sheets.Item[0];
// Determine slice which is a source for data area:
DI.Slice := DtSource.Slices.Item[0];
// Determine cell range where data area is located:
Range := Report.ParseCell(DI.Sheet.Name+"!A0").Range;
DI.Range := Range;
MObj.Save();
End Sub;
After executing the example a slice is added for regular report; a data area will be based on this slice and located on the specified sheet.
Consider an example of adding a data slice and analytical data area to regular report.
Executing the example requires that the repository contains:
A regular report with the REPORT identifier.
A cube with the CUBE_SEP identifier containing five dimensions.
Add links to the Cubes, Drawing, Express, Matrix, Metabase, Pivot, Report, Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
DA: IEaxDataArea;
Slice: IEaxDataAreaSlice;
DtSource: IPrxDataSource;
Pivot: IPivot;
CubeInst: ICubeInstance;
View: IEaxObject;
Sheet: IPrxSheet;
Table: ITabSheet;
Rect: IGxRect;
ViewSets: IEaxGridViewSettings;
T_Header, L_Header: IDataAreaHeaderSettingsBase;
Begin
// Get a repository
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REPORT").Edit As IPrxReport;
// Get data area
DA := Report.DataArea;
// Add a data slice
Slice := DA.Slices.Add(EaxDataAreaSliceType.Pivot);
Slice.Execute;
Slice.CreateSource;
// Get a source
CubeInst := MetabaseClass.Active.ItemById("CUBE_SEP").Open(Null) As ICubeInstance;
// Get data table
Pivot := (Slice As IEaxDataAreaPivotSlice).Pivot;
// Place source in the table
Pivot.DataSource := CubeInst.Destinations.DefaultDestination As IMatrixDataSource;
DtSource := Report.DataSources.Add(Pivot.DataSource);
// Put elements to the dimension selection
Pivot.Selection.Item(0).SelectElement(0, False);
Pivot.Selection.Item(1).SelectAll;
Pivot.Selection.Item(2).SelectElement(0, False);
Pivot.Selection.Item(3).SelectAll;
Pivot.Selection.Item(4).SelectElement(0, False);
// Set dimensions to table title
Pivot.TopHeader.AddDim(Pivot.DimItem(1)); // Calendar
Pivot.LeftHeader.AddDim(Pivot.DimItem(3)); // Territory
Pivot.FixedHeader.AddDim(Pivot.DimItem(2)); // SEI
Pivot.FixedHeader.AddDim(Pivot.DimItem(0)); // Facts
Pivot.FixedHeader.AddDim(Pivot.DimItem(4)); // Data types
// Create table data view
Report.Sheets.Remove(1);
View := Slice.Views.AddByType(EaxObjectType.Grid);
(View As IEaxGrid).Pivot := Pivot;
// View will be at the sheet
Sheet := Report.Sheets.Add("Sheet2");
Table := (Sheet As IPrxTable).TabSheet;
(View As IEaxGrid).TabSheet := Table;
// Set table range
Rect := New GxRect.Create(0, 3, 0, 3);
(View As IEaxGrid).OutputRect := Rect;
// Set insert methods
ViewSets := (View As IEaxGrid).ViewSettings;
T_Header := (View As IEaxGrid).Pivot.TopHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(T_Header) As IEaxGridHeaderSettings)
Behaviour := EaxGridHeaderBehaviour.Insert;
L_Header := (View As IEaxGrid).Pivot.LeftHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(L_Header) As IEaxGridHeaderSettings)
Behaviour := EaxGridHeaderBehaviour.Insert;
// Update report and save changes
Report.Recalc;
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a new data slice is created in regular report, and analytical data area is built by it on the second report sheet.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Pivot;
Imports Prognoz.Platform.Interop.Report;;
Imports Prognoz.Platform.Interop.Tab;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
DA: IEaxDataArea;
Slice: IEaxDataAreaSlice;
DtSource: IPrxDataSource;
Pivot: PivotFactory;
CubeInst: ICubeInstance;
View: IEaxObject;
Sheet: IPrxSheet;
Table: TabSheet;
Rect: GxRect = New GxRectClass();
ViewSets: IEaxGridViewSettings;
T_Header, L_Header: IDataAreaHeaderSettingsBase;
Begin
// Get repository
MB := Params.Metabase;
// Get regular report
Report := MB.ItemById["REPORT"].Edit() As IPrxReport;
// Get data area
DA := Report.DataArea;
// Add data slice
Slice := DA.Slices.Add(EaxDataAreaSliceType.edastPivot);
Slice.Execute();
Slice.CreateSource();
// Get a source
CubeInst := Params.Metabase.ItemById["CUBE_SEP"].Open(Null) As ICubeInstance;
// Get data table
Pivot := (Slice As IEaxDataAreaPivotSlice).Pivot;
// Put source to the table
Pivot.DataSource := CubeInst.Destinations.DefaultDestination As IMatrixDataSource;
DtSource := Report.DataSources.Add(Pivot.DataSource);
// Put elements to the selection
Pivot.Selection.Item[0].SelectElement(0, False);
Pivot.Selection.Item[1].SelectAll();
Pivot.Selection.Item[2].SelectElement(0, False);
Pivot.Selection.Item[3].SelectAll();
Pivot.Selection.Item[4].SelectElement(0, False);
// Set dimensions to table titles
Pivot.TopHeader.AddDim(Pivot.DimItem[1]); // Calendar
Pivot.LeftHeader.AddDim(Pivot.DimItem[3]); // Territory
Pivot.FixedHeader.AddDim(Pivot.DimItem[2]); // SEI
Pivot.FixedHeader.AddDim(Pivot.DimItem[0]); // Facts
Pivot.FixedHeader.AddDim(Pivot.DimItem[4]); // Data types
// Create data table view
View := Slice.Views.AddByType(EaxObjectType.eotGrid);
(View As IEaxGrid).Pivot := Pivot;
// View will be on the second sheet
Report.Sheets.Remove(1);
Sheet := Report.Sheets.Add("Sheet2", PrxSheetType.pstTable);
Table := (Sheet As IPrxTable).TabSheet;
(View As IEaxGrid).TabSheet := Table;
// Set table range
Rect.Create(0, 3, 0, 3);
(View As IEaxGrid).OutputRect := Rect;
// Set insert methods
ViewSets := (View As IEaxGrid).ViewSettings;
T_Header := (View As IEaxGrid).Pivot.TopHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings[T_Header] As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.eghbInsert;
L_Header := (View As IEaxGrid).Pivot.LeftHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings[L_Header] As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.eghbInsert;
// Update report and save changes
Report.Recalc();
(Report As IMetabaseObject).Save();
End Sub;
After executing the example a new data slice is created in regular report, and analytical data area is built by it on the second report sheet.
See also:
General Principles of Programming using the Report Assembly
Fore Example