Setting Up Data Slice, Data Area and Analytical Data Area

A regular report contains various types of data areas:

Setting Up Data Slice and Data Area

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;

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.

Setting Up Analytical Data Area, Data Slice and Table Visualizer

Consider example of setting up analytical data area, slice and table visualizer.

Executing the example requires that the repository contains:

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(NullAs 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(0False);
    Pivot.Selection.Item(
1).SelectLevel(0);
    Pivot.Selection.Item(
2).SelectElement(0False);
    Pivot.Selection.Item(
3).SelectChildren(1False);
    Pivot.Selection.Item(
4).SelectElement(0False);
    
// 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(0303);
    (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;

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:

General Principles of Programming using the Report Assembly