GemBox.Spreadsheet

ExcelColumnRowBase.OutlineLevel Property

Gets or sets outline level.

public int OutlineLevel {get; set;}

Remarks

Exception is thrown if value is out of 0 to 7 range.

Using this property you can create hierarchical groups. Range of consecutive objects (rows or columns) with the same value of outline level belongs to the same group. Default value is zero, which prevents grouping. Collapsed property determines whether group is collapsed or expanded in outlining.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThrown if value is out of 0 to 7 range.

Example

Following code creates two horizontal groups and one vertical group. Horizontal groups have outline button above (default is below), while vertical group is collapsed.

[Visual Basic]
    Sub GroupingSample(ByVal ws As ExcelWorksheet)
        ws.Cells(0, 0).Value = "Grouping and outline example:"

        ' Vertical grouping.
        ws.Cells(2, 0).Value = "GroupA Start"
        ws.Rows(2).OutlineLevel = 1
        ws.Cells(3, 0).Value = "A"
        ws.Rows(3).OutlineLevel = 1
        ws.Cells(4, 1).Value = "GroupB Start"
        ws.Rows(4).OutlineLevel = 2
        ws.Cells(5, 1).Value = "B"
        ws.Rows(5).OutlineLevel = 2
        ws.Cells(6, 1).Value = "GroupB End"
        ws.Rows(6).OutlineLevel = 2
        ws.Cells(7, 0).Value = "GroupA End"
        ws.Rows(7).OutlineLevel = 1
        ' Put outline row buttons above groups.
        ws.OutlineRowButtonsBelow = False

        ' Horizontal grouping (collapsed).
        ws.Cells("E2").Value = "Gr.C Start"
        ws.Columns("E").OutlineLevel = 1
        ws.Columns("E").Collapsed = True
        ws.Cells("F2").Value = "C"
        ws.Columns("F").OutlineLevel = 1
        ws.Columns("F").Collapsed = True
        ws.Cells("G2").Value = "Gr.C End"
        ws.Columns("G").OutlineLevel = 1
        ws.Columns("G").Collapsed = True
    End Sub
[C#]
    static void GroupingSample(ExcelWorksheet ws)
    {
        ws.Cells[0,0].Value = "Grouping and outline example:";

        // Vertical grouping.
        ws.Cells[2,0].Value = "GroupA Start";
        ws.Rows[2].OutlineLevel = 1;
        ws.Cells[3,0].Value = "A";
        ws.Rows[3].OutlineLevel = 1;
        ws.Cells[4,1].Value = "GroupB Start";
        ws.Rows[4].OutlineLevel = 2;
        ws.Cells[5,1].Value = "B";
        ws.Rows[5].OutlineLevel = 2;
        ws.Cells[6,1].Value = "GroupB End";
        ws.Rows[6].OutlineLevel = 2;
        ws.Cells[7,0].Value = "GroupA End";
        ws.Rows[7].OutlineLevel = 1;
        // Put outline row buttons above groups.
        ws.OutlineRowButtonsBelow = false;

        // Horizontal grouping (collapsed).
        ws.Cells["E2"].Value = "Gr.C Start";
        ws.Columns["E"].OutlineLevel = 1;
        ws.Columns["E"].Collapsed = true;
        ws.Cells["F2"].Value = "C";
        ws.Columns["F"].OutlineLevel = 1;
        ws.Columns["F"].Collapsed = true;
        ws.Cells["G2"].Value = "Gr.C End";
        ws.Columns["G"].OutlineLevel = 1;
        ws.Columns["G"].Collapsed = true;
    }

See Also

ExcelColumnRowBase Class | GemBox.Spreadsheet Namespace | Collapsed