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.Exclude(CellRange) Method

Excludes the specified cell or cell range from the current range.

Namespace: DevExpress.Spreadsheet

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

Declaration

CellRange Exclude(
    CellRange other
)
Function Exclude(
    other As CellRange
) As CellRange
CellRange Exclude(
    CellRange other
)
Function Exclude(
    other As CellRange
) As CellRange
CellRange Exclude(
    CellRange other
)
Function Exclude(
    other As CellRange
) As CellRange

Parameters

Name Type Description
other CellRange

A CellRange object that specifies the cell or cell range to be excluded from the source range.

Parameters

Name Type Description
other CellRange

A CellRange object that specifies the cell or cell range to be excluded from the source range.

Parameters

Name Type Description
other CellRange

A CellRange object that specifies the cell or cell range to be excluded from the source range.

Returns

Type Description
CellRange

A CellRange object that is the resulting contiguous or noncontiguous (union) range of cells.

Returns

Type Description
CellRange

A CellRange object that is the resulting contiguous or noncontiguous (union) range of cells.

Returns

Type Description
CellRange

A CellRange object that is the resulting contiguous or noncontiguous (union) range of cells.

Remarks

Use the Exclude method to exclude a specific cell or cell range from the cell range that calls this method. Take into account the following special cases.

  • If the other parameter of this method is null or a cell range you wish to exclude doesn't intersect the source range, the entire source range will be returned.
  • If you exclude all cells from the source range, the Exclude method will return null.
  • If a cell or cell range you wish to exclude from the current range is located on another worksheet, the InvalidOperationException will be thrown.

The following example demonstrates how to use the Exclude method to exclude a specific cell range from the CellRange object.

using DevExpress.Spreadsheet;
using System.Drawing;
// ...

IWorkbook workbook = spreadsheetControl1.Document;
Worksheet worksheet = workbook.Worksheets["Sheet1"];
CellRange sourceRange = worksheet.Range["B2:E7"];
CellRange excludedRange = worksheet.Range["C4:D5"];

// Exclude the cell range "C4:D5" from the range "B2:E7".
CellRange resultantRange = sourceRange.Exclude(excludedRange);

// Fill the resultant cell range with the specified color. 
resultantRange.Fill.BackgroundColor = Color.FromArgb(0xFA, 0xDA, 0xDD);

The result of code execution is shown in the image below.

SpreadsheetControl_ExcludedCellRange

To combine multiple cell ranges in a worksheet into a single complex range, use the CellRange.Union method.

See Also