Description
A Range object represents a range in a workbook.
C#
vb.net
Remarks
A range is a collection of areas. An area is a rectangular collection of cells. The areas in a range may be non-adjacent, and a range can include areas in different worksheets.
To create a Range
(without a name), call one of the following methods:
If a range is named, it will be accessible when the workbook is opened in Microsoft Excel. To create a named range, call one of the following methods:
- Workbook.CreateNamedRange(rangeFormula, rangeName)
- Worksheet.CreateNamedRange(firstRow, firstColumn, numRows, numColumns, rangeName)
- Worksheet.CreateNamedRange(rangeFormula, rangeName)
Examples
C#
vb.net
Properties
Name |
Description |
---|---|
Returns the number of Area objects contained in this Range. | |
Returns an array of the rectangular areas contained in the Range. | |
Returns a Border object that represents a border around the range. | |
Returns the style for the first cell in the range. Changes to this style will apply only to the first cell. To assign this style to the entire Range, set Range.SetStyle() to this Style reference. |
Indexers
Name |
Description |
---|---|
Returns the Area object at the specified 0-based index. |
Methods
Name |
Description |
---|---|
Applies a style to the area. When a style is applied - rather than set (see Range.SetStyle ) - only the differences between the new style and style properties previously assigned to the range (through the ExcelWriter API) will take effect. For example, if the range has a background color and the new style applied does not contain a background color, the area's color will not be affected. | |
Clears the content of all cells in the range. Calling this method is equivalent to setting an range's style to "Normal" and its cell values to null. | |
Adds another range to this range. | |
This method removes any ConditionalFormat objects from the Range. | |
This method copies the specified ConditionaFormat object and associates it with this Range. If any ConditionalFormat objects already exist within the Range, they will be removed and replaced by the specifed one. | |
Assigns a data validation rule to all cells in the Range. If the DataValidation object uses a local reference or area in a formula (i.e. "=A5:B7"), then the range will adjust those local references accordingly based on the range's location. The original DataValidation object will not be affected. |
|
Sets the style for every cell in this range. When a style is set - rather than applied (see Range.ApplyStyle ) - all previously assigned style properties, including font and number formatting, will be overwritten for all cells in the range. | |
Returns a string representation of the Range object. |