Class Range
public class Range
- Inheritance
-
Range
- Inherited Members
Constructors
Range(Worksheet, uint, uint, uint, uint)
Initializes a new instance of the Range class.
public Range(Worksheet worksheet, uint startRowIndex, uint startColumnIndex, uint endRowIndex, uint endColumnIndex)
Parameters
worksheet
WorksheetThe worksheet to which this range belongs.
startRowIndex
uintThe starting row index of the range.
startColumnIndex
uintThe starting column index of the range.
endRowIndex
uintThe ending row index of the range.
endColumnIndex
uintThe ending column index of the range.
Exceptions
- ArgumentNullException
Thrown if the provided worksheet is null.
- ArgumentOutOfRangeException
Thrown if the start or end row/column indices are out of range.
Properties
ColumnCount
Gets the count of columns in the range. This property calculates the column count based on the start and end column indices.
public uint ColumnCount { get; }
Property Value
- uint
The count of columns in the range.
Exceptions
- InvalidOperationException
Thrown if the end column index is less than the start column index.
EndColumnIndex
public uint EndColumnIndex { get; }
Property Value
EndRowIndex
public uint EndRowIndex { get; }
Property Value
RowCount
Gets the count of rows in the range. This property calculates the row count based on the start and end row indices.
public uint RowCount { get; }
Property Value
- uint
The count of rows in the range.
Exceptions
- InvalidOperationException
Thrown if the end row index is less than the start row index.
StartColumnIndex
public uint StartColumnIndex { get; }
Property Value
StartRowIndex
public uint StartRowIndex { get; }
Property Value
Methods
AddDropdownListValidation(string[])
Adds dropdown list validation with the specified options to all cells within the range.
public void AddDropdownListValidation(string[] options)
Parameters
options
string[]The list of options for the dropdown validation.
Exceptions
- ArgumentNullException
Thrown if the options array is null or empty.
- InvalidOperationException
Thrown if adding dropdown validation fails for any cell within the range.
ApplyValidation(ValidationRule)
public void ApplyValidation(ValidationRule rule)
Parameters
rule
ValidationRule
ClearCells()
Clears the values and resets the style of all cells within the range.
public void ClearCells()
Exceptions
- InvalidOperationException
Thrown if any cell within the range is not properly initialized or accessible.
MergeCells()
Merges all cells within the range into a single cell.
public void MergeCells()
Exceptions
- InvalidOperationException
Thrown if the merge operation fails, for example, if the cells cannot be merged.
SetValue(string)
Sets the specified value to all cells within the range.
public void SetValue(string value)
Parameters
value
stringThe value to set in each cell of the range.
Exceptions
- InvalidOperationException
Thrown if any cell within the range is not properly initialized or accessible.