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_1 identifier.
Sub Main;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Expr: IEaxAnalyzer;
Cube: ICubeInstance;
Pivot: IPivot;
Totals: IPivotEvaluatorTotals;
HighItem: IPivotHighlightItem;
Sort: IPivotSorterData;
Styles: IEaxTableStyle;
Style: 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;
//A cube, for which an express report is created
Cube := MB.ItemById("Cube_1").Open(Null) As ICubeInstance;
Expr.OpenCube(Cube);
Pivot := Expr.Pivot;
//Totals
Totals := Pivot.Evaluator.Totals;
Totals.RowTypes := PivotEvaluatorElementType.Sum + PivotEvaluatorElementType.Max;
Totals.IncludeOwner := True;
Totals.TreatEmptyAsZero := False;
//Data highlighting 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;
//Sorting by columns
Sort := Pivot.Sorter.ColumnsDataSort;
Sort.SortDirection(0) := PivotSortDirection.Asc;
//Display styles setting
Styles := Expr.Grid.Style;
//Total values display style
Style := Styles.TotalsStyle;
Style.HorizontalAlignment := TabFormatAlignment.Center;
Style.BackgroundColor := GxColor.FromName("LightGray");
Style.Font.Color := GxColor.FromName("Red");
//Highlighted cells display style
Style := Styles.HighlightedStyle;
Style.BackgroundColor := GxColor.FromName("Yellow");
Style.Font.Bold := TriState.OnOption;
Style.Font.Color := GxColor.FromName("Blue");
(Expr As IMetabaseObject).Save;
End Sub Main;
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. Ascending sorting of values is enabled for the first column.
See also: