Creating an Express Report

Below is the example of creating a new express report including setting up data displaying. Executing the example requires that the repository contains a cube with the CUBE identifier.

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    Expr: IEaxAnalyzer;
    Cube: ICubeInstance;
    Pivot: IPivot;
    Totals: IPivotEvaluatorTotals;
    HighItem: IPivotHighlightItem;
    HeaderSettings: IEaxDataAreaCellStyle;
    Styles: IEaxGrid;
    Style: ITabCellStyle;
    TabStyle: ITabCellStyle;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_EXPRESSREPORT;
    CrInfo.Id := "NEWEXPRESS";
    CrInfo.Parent := MB.Root;
    Expr := MB.CreateObject(CrInfo).Edit As IEaxAnalyzer;
    //Cube, for which express report is created
    Cube := MB.ItemById("CUBE").Open(NullAs ICubeInstance;
    Expr.OpenCube(Cube);
    Pivot := Expr.Pivot;
    //Totals
    Totals := Pivot.Evaluator.Totals;
    Totals.RowTypes := PivotEvaluatorElementType.Sum + PivotEvaluatorElementType.Max;
    Totals.IncludeOwner := True;
    Totals.TreatEmptyAsZero := False;
    //Highlight data in the range [100;200]
    HighItem := Pivot.Highlight.Add;
    HighItem.ConditionType := PivotHighlightType.NLAandNGB;
    HighItem.ConditionValueA := 100;
    HighItem.ConditionValueB := 200;
    HighItem.Area := PivotFilterArea.Table;
    HighItem.Enabled := True;
    //Set up display styles
    Styles := Expr.Grid;
    HeaderSettings := Styles.ViewSettings.GetViewSettings(Pivot As IDataAreaHeaderSettingsBase) As IEaxDataAreaCellStyle;
    //Style for displaying of totals
    Style := HeaderSettings.Data;
    Style.HorizontalAlignment := TabFormatAlignment.Center;
    Style.BackgroundBrush := New GxSolidBrush.Create(GxColor.FromName("LightGray"));
    Style.Font.Color := GxColor.FromName("Red");
    //Style for displaying of highlighted cells
    TabStyle := Styles.Style.HighlightedStyle;
    TabStyle.BackgroundBrush := New GxSolidBrush.Create(GxColor.FromName("Yellow"));
    TabStyle.Font.Bold := TriState.OnOption;
    TabStyle.Font.Color := GxColor.FromName("Blue");
    (Expr As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a new express report is created for the specified cube in the repository root. The totals - values sum and maximum value - are displayed by columns in the data table. Values that fall into the range of [100;200] are highlighted with blue color on yellow background.

See also:

Examples