officefileapi-devexpress-dot-spreadsheet-dot-columncollection-dot-group-x28-system-dot-int32-system-dot-int32-system-dot-boolean-x29.md
Groups the specified columns on a worksheet.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
void Group(
int first,
int last,
bool collapse
)
Sub Group(
first As Integer,
last As Integer,
collapse As Boolean
)
| Name | Type | Description |
|---|---|---|
| first | Int32 |
A zero-based integer representing the index of the first column to be grouped.
| | last | Int32 |
A zero-based integer representing the index of the last column to be grouped.
| | collapse | Boolean |
true , if the created group is collapsed; otherwise, false.
|
To group columns in a worksheet, call the ColumnCollection.Group method of the ColumnCollection object. This object represents a collection of all columns contained in a worksheet and is accessed using the Worksheet.Columns property. Pass the indexes of the first and last columns to be grouped, and a value indicating whether the new group should be expanded or collapsed.
Note that you can also place one group of columns inside another. But the number of nested groups is limited: you can create a maximum of seven levels of grouping.
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
' Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, False)
The following code snippets (auto-collected from DevExpress Examples) contain references to the Group(Int32, Int32, Boolean) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns
// Group columns "C" through "F" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns
// Group eight columns (from the third column to the tenth column).
worksheet.Columns.Group(2, 9, true);
#endregion #GroupColumns
' Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns
' Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns
' Group columns "C" through "F" and expand the group.
worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns
' Group eight columns (from the third column to the tenth column).
worksheet.Columns.Group(2, 9, True)
#End Region ' #GroupColumns
See Also