All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

CellRange.GetMinimumCover() Method

Returns the cell range that covers the current range and does not contain the intersecting ranges.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

CellRange GetMinimumCover()
Function GetMinimumCover As CellRange
CellRange GetMinimumCover()
Function GetMinimumCover As CellRange
CellRange GetMinimumCover()
Function GetMinimumCover As CellRange

Returns

Type Description
CellRange

A CellRange object that is a contiguous or noncontiguous (union) range that covers the same cells as the current range excluding the intersecting areas.

Returns

Type Description
CellRange

A CellRange object that is a contiguous or noncontiguous (union) range that covers the same cells as the current range excluding the intersecting areas.

Returns

Type Description
CellRange

A CellRange object that is a contiguous or noncontiguous (union) range that covers the same cells as the current range excluding the intersecting areas.

Remarks

Use the GetMinimumCover method to get a cell range that consists of non-intersecting ranges whose union equals the current range. This can be useful when you need to obtain all cells of a complex range without intersecting areas (e.g., to perform calculations on these cells).

For instance, let's consider you need to count the number of cells in a multiple-area selection (B2:C4, C4:E7 and E2:F4, in the image below) that contains duplicated cells (C4 and E4).

Spreadsheet_SelectedRange_Complex

To solve this task, call the GetMinimumCover method for a union range of selected areas the Worksheet.Selection property returns. The resulting union range contains the same cells as the selected ranges, but without intersecting areas.

Spreadsheet_Range_GetMinimumCover

The code snippet below demonstrates this approach:

IWorkbook workbook = spreadsheetControl.Document;
Worksheet worksheet = workbook.Worksheets.ActiveWorksheet;

// Get the range that covers the selected cells, 
// but does not contain the intersecting areas.
CellRange selectedCells = worksheet.Selection.GetMinimumCover();

// Count the number of selected cells.
int cellCount = 0;
foreach (CellRange range in selectedCells.Areas)
    cellCount += range.RowCount * range.ColumnCount;
See Also