Setting Up Several Calculated Statistics

Example

Executing the example requires a form containing the following components:

Add links to the following system assemblies:

The example handles the OnClick event for the Button1 component:

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    EaxStat: IEaxStatistics;
    Tree: ITsStatisticsTree;
    i: integer;
    Nodes: ITreeListNodes;
    StatNode, ParentNode: ITreeListNode;
    HashT: IHashtable;
    Wbk: IEaxWorkbook;
Begin
    EaxStat := UiErAnalyzer1.ErAnalyzer.Statistics;
    Wbk := UiErAnalyzer1.ErAnalyzer As IEaxWorkbook;
    Wbk.Statistics.Visible := True;
    Wbk.Statistics.Enabled := True;
    // Exclude part of statistics from tree creation
    EaxStat.StatisticsVisible(TsStatisticsType.Max) := False;
    EaxStat.StatisticsVisible(TsStatisticsType.Min) := False;
    EaxStat.StatisticsVisible(TsStatisticsType.Average) := False;
    // Get statistics
    Tree := EaxStat.AllStatistics;
    // Clear the component to display statistics tree
    Nodes := TreeList1.Nodes;
    Nodes.Clear;
    // Build the tree
    If Tree = Null Then
        Return;
    End If;
    HashT := New Hashtable.Create;
    For i := 0 To Tree.Count - 1 Do
        ParentNode := Null;
        If Tree.ParentNode(i) <> -1 Then
            ParentNode := HashT(Tree.ParentNode(i));
        End If;
        StatNode := Nodes.AddChild(ParentNode, Tree.Name(i));
        If Tree.Type(i) <> TsStatisticsTreeNodeType.Category Then
            StatNode.ColumnText(1) := Tree.Value(i);
        End If;
        StatNode.Data := i;
        HashT(i) := StatNode;
    End For;
    HashT.Clear;
    Nodes.TreeControl.InnerRoot.Expand(True);
End Sub Button1OnClick;

After executing the example on clicking the button the statistics tree is built for the workbook table. The tree does not display the Minimum, Maximum and Average values.

See also:

Examples | ILaner