A regular report contains various types of data areas:
Data area. Outdated type of data table based on a data slice. It is used only in the Foresight. Analytics PlatformReports tool and is calculated only using formulas.
Table visualizer. A new type of data table based on a slice. Opposite the data area, it is used in all reporting tools and is calculated by modeling methods. To work with it, use the IEaxGrid interface.
Analytical data area. An object that includes providers, slices, visualizers, transformations, validations of report. It is used in all reporting tools. To work with it, use the IEaxDataArea interface.
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.
Add links to the Metabase, Report, 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 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 a slice being 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;
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 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 a slice being 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 example of setting up analytical data area, slice and table visualizer.
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, Dimensions, 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;
Grid: IEaxGrid;
Style: IEaxTableStyle;
Rect: IGxRect;
ViewSets: IEaxGridViewSettings;
T_Header, L_Header: IDataAreaHeaderSettingsBase;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REPORT").Edit As IPrxReport;
// Get analytical data area
DA := Report.DataArea;
DA.Clear;
Report.DataSources.Clear;
// Add a data slice
Slice := DA.Slices.Add(EaxDataAreaSliceType.Pivot);
Slice.CreateSource;
// Get basis for table
Pivot := (Slice As IEaxDataAreaPivotSlice).Pivot;
// Get provider
CubeInst := MetabaseClass.Active.ItemById["CUBE_SEP"].Open(Null) As ICubeInstance;
// Place provider in the table basis
Pivot.DataSource := CubeInst.Destinations.DefaultDestination As IMatrixDataSource;
DtSource := Report.DataSources.Add(Pivot.DataSource);
// Set elements to the dimensions selection
Pivot.Selection.Item(0).SelectElement(0, False);
Pivot.Selection.Item(1).SelectLevel(0);
Pivot.Selection.Item(2).SelectElement(0, False);
Pivot.Selection.Item(3).SelectChildren(1, False);
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)); // Territories
Pivot.FixedHeader.AddDim(Pivot.DimItem(2)); // SEF
Pivot.FixedHeader.AddDim(Pivot.DimItem(0)); // Facts
Pivot.FixedHeader.AddDim(Pivot.DimItem(4)); // Data types
// Create a table view
Report.Sheets.Remove(1);
View := Slice.Views.AddByType(EaxObjectType.Grid);
Grid := View As IEaxGrid;
Grid.Pivot := Pivot;
// Add a sheet and put table on it
Sheet := Report.Sheets.Add("Sheet2");
Table := (Sheet As IPrxTable).TabSheet;
Grid.TabSheet := Table;
// Set table formatting
Style := Grid.Style;
Style.TableStyle.AssignPredefined(TabTablePredefinedStyle.ExtBlue);
// Set table range
Rect := New GxRect.Create(0, 3, 0, 3);
(View As IEaxGrid).OutputRect := Rect;
// Set insertion methods
ViewSets := Grid.ViewSettings;
T_Header := Grid.Pivot.TopHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(T_Header) As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.Insert;
L_Header := Grid.Pivot.LeftHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(L_Header) As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.Insert;
// Refresh report and save changes
Report.Recalc;
(Report As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
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: IPivot;
CubeInst: ICubeInstance;
View: IEaxObject;
Sheet: IPrxSheet;
Table: ITabSheet;
Grid: IEaxGrid;
Style: IEaxTableStyle;
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 analytical data area
DA := Report.DataArea;
DA.Clear();
Report.DataSources.Clear();
// Add a data slice
Slice := DA.Slices.Add(EaxDataAreaSliceType.edastPivot);
Slice.CreateSource();
// Get basis for table
Pivot := (Slice As IEaxDataAreaPivotSlice).Pivot;
// Get provider
CubeInst := Params.Metabase.ItemById["CUBE_SEP"].Open(Null) As ICubeInstance;
// Place provider in the table basis
Pivot.DataSource := CubeInst.Destinations.DefaultDestination As IMatrixDataSource;
DtSource := Report.DataSources.Add(Pivot.DataSource);
// Set elements to the dimensions selection
Pivot.Selection.Item[0].SelectElement(0, False);
Pivot.Selection.Item[1].SelectLevel(0);
Pivot.Selection.Item[2].SelectElement(0, False);
Pivot.Selection.Item[3].SelectChildren(1, False);
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]); // Territories
Pivot.FixedHeader.AddDim(Pivot.DimItem[2]); // SEF
Pivot.FixedHeader.AddDim(Pivot.DimItem[0]); // Facts
Pivot.FixedHeader.AddDim(Pivot.DimItem[4]); // Data types
// Create a table view
Report.Sheets.Remove(1);
View := Slice.Views.AddByType(EaxObjectType.eotGrid);
Grid := View As IEaxGrid;
Grid.Pivot := Pivot As PivotFactory;
// Add a sheet and put table on it
Sheet := Report.Sheets.Add("Sheet2", PrxSheetType.pstTable);
Table := (Sheet As IPrxTable).TabSheet;
Grid.TabSheet := Table As TabSheet;
// Set table formatting
Style := Grid.Style;
Style.TableStyle.AssignPredefined(TabTablePredefinedStyle.ttpsExtBlue);
// Set table range
Rect.Create(0, 3, 0, 3);
(View As IEaxGrid).OutputRect := Rect;
// Set insertion methods
ViewSets := Grid.ViewSettings;
T_Header := Grid.Pivot.TopHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings[T_Header] As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.eghbInsert;
L_Header := Grid.Pivot.LeftHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings[L_Header] As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.eghbInsert;
// Refresh report and save changes
Report.Recalc();
(Report As IMetabaseObject).Save();
End Sub;
After executing the example data provider will be added to the regular report, a new data slice will be created in analytical area and the table will be built based on it on the second report sheet.
See also: