Class CellRange
- Namespace
- BigExcelCreator.Ranges
- Assembly
- BigExcelCreator.dll
Represents a range of cells in an Excel sheet.
public class CellRange : IEquatable<CellRange>, IComparable<CellRange>
- Inheritance
-
CellRange
- Implements
- Inherited Members
Remarks
This class provides properties and methods to handle cell ranges, including their dimensions, overlap checks, and string representations.
Constructors
CellRange(int?, bool, int?, bool, int?, bool, int?, bool, string)
Initializes a new instance of the CellRange class using coordinates indexes.
public CellRange(int? startingColumn, bool fixedStartingColumn, int? startingRow, bool fixedStartingRow, int? endingColumn, bool fixedEndingColumn, int? endingRow, bool fixedEndingRow, string sheetname)
Parameters
startingColumn
int?The starting column of the cell range.
fixedStartingColumn
boolIndicates whether the starting column is fixed.
startingRow
int?The starting row of the cell range.
fixedStartingRow
boolIndicates whether the starting row is fixed.
endingColumn
int?The ending column of the cell range.
fixedEndingColumn
boolIndicates whether the ending column is fixed.
endingRow
int?The ending row of the cell range.
fixedEndingRow
boolIndicates whether the ending row is fixed.
sheetname
stringThe name of the sheet.
Exceptions
- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the range is invalid.
CellRange(int?, bool, int?, bool, string)
Initializes a new instance of the CellRange class using coordinates indexes.
public CellRange(int? column, bool fixedColumn, int? row, bool fixedRow, string sheetname)
Parameters
column
int?The column of the cell range.
fixedColumn
boolIndicates whether the column is fixed.
row
int?The row of the cell range.
fixedRow
boolIndicates whether the row is fixed.
sheetname
stringThe name of the sheet.
Exceptions
- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the range is invalid.
CellRange(int?, int?, int?, int?, string)
Initializes a new instance of the CellRange class using coordinates indexes.
public CellRange(int? startingColumn, int? startingRow, int? endingColumn, int? endingRow, string sheetname)
Parameters
startingColumn
int?The starting column of the cell range.
startingRow
int?The starting row of the cell range.
endingColumn
int?The ending column of the cell range.
endingRow
int?The ending row of the cell range.
sheetname
stringThe name of the sheet.
Exceptions
- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the range is invalid.
CellRange(int?, int?, string)
Initializes a new instance of the CellRange class using coordinates indexes.
public CellRange(int? column, int? row, string sheetname)
Parameters
column
int?The column of the cell range.
row
int?The row of the cell range.
sheetname
stringThe name of the sheet.
Exceptions
- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the range is invalid.
CellRange(string)
Initializes a new instance of the CellRange class from a string representation of a range.
public CellRange(string range)
Parameters
range
stringThe range string to initialize the cell range.
Exceptions
- ArgumentNullException
If
range
is null- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the
range
does not represent a valid range.
Properties
EndingColumn
Gets the ending column of the cell range.
public int? EndingColumn { get; }
Property Value
- int?
The ending column of the cell range, or null if the ending column is not specified.
EndingColumnIsFixed
true if the ending column is fixed
Represented by '$' in the string representation
public bool EndingColumnIsFixed { get; }
Property Value
EndingRow
Gets the ending row of the cell range.
public int? EndingRow { get; }
Property Value
- int?
The ending row of the cell range, or null if the ending row is not specified.
EndingRowIsFixed
true if the ending row is fixed
Represented by '$' in the string representation
public bool EndingRowIsFixed { get; }
Property Value
Height
Gets the height of the cell range.
public int Height { get; }
Property Value
IsInfiniteCellRange
Gets a value indicating whether the cell range is infinite.
public bool IsInfiniteCellRange { get; }
Property Value
- bool
True if the cell range is infinite; otherwise, false.
IsInfiniteCellRangeCol
Gets a value indicating whether the cell range represents an entire column.
public bool IsInfiniteCellRangeCol { get; }
Property Value
- bool
True if the cell range represents an entire column; otherwise, false.
IsInfiniteCellRangeRow
Gets a value indicating whether the cell range represents an entire row.
public bool IsInfiniteCellRangeRow { get; }
Property Value
- bool
True if the cell range represents an entire row; otherwise, false.
IsSingleCellRange
Gets a value indicating whether the cell range represents a single cell.
public bool IsSingleCellRange { get; }
Property Value
- bool
True if the cell range represents a single cell; otherwise, false.
RangeString
Gets the range string representation of the cell range, including the sheet name if available.
public string RangeString { get; }
Property Value
- string
The range string representation of the cell range, including the sheet name if available.
RangeStringNoSheetName
Gets the range string representation of the cell range without the sheet name.
public string RangeStringNoSheetName { get; }
Property Value
- string
The range string representation of the cell range without the sheet name.
Sheetname
Gets or sets the sheet name of the cell range.
public string Sheetname { get; set; }
Property Value
- string
The sheet name of the cell range.
Exceptions
- InvalidRangeException
Thrown when the sheet name contains invalid characters.
StartingColumn
Gets the starting column of the cell range.
public int? StartingColumn { get; }
Property Value
- int?
The starting column of the cell range, or null if the starting column is not specified.
StartingColumnIsFixed
true if the starting column is fixed
Represented by '$' in the string representation
public bool StartingColumnIsFixed { get; }
Property Value
StartingRow
Gets the starting row of the cell range.
public int? StartingRow { get; }
Property Value
- int?
The starting row of the cell range, or null if the starting row is not specified.
StartingRowIsFixed
true if the starting row is fixed
Represented by '$' in the string representation
public bool StartingRowIsFixed { get; }
Property Value
Width
Gets the width of the cell range.
public int Width { get; }
Property Value
Methods
CompareTo(CellRange)
Compares the current instance with another CellRange and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other CellRange.
public int CompareTo(CellRange other)
Parameters
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
- Less than zero: This instance precedes
other
in the sort order. - Zero: This instance occurs in the same position in the sort order as
other
. - Greater than zero: This instance follows
other
in the sort order.
- Less than zero: This instance precedes
Equals(CellRange)
public virtual bool Equals(CellRange other)
Parameters
Returns
Equals(object)
Determines whether the specified object is equal to the current CellRange instance.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
True if the specified object is a CellRange and is equal to the current instance; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer hash code.
RangeOverlaps(CellRange)
public bool RangeOverlaps(CellRange other)
Parameters
Returns
Exceptions
- ArgumentNullException
other
isnull
.
Operators
operator ==(CellRange, CellRange)
Determines whether two specified CellRange objects have the same value.
public static bool operator ==(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is the same as the value ofright
; otherwise,false
.
operator >(CellRange, CellRange)
public static bool operator >(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is greater than the value ofright
; otherwise,false
.
operator >=(CellRange, CellRange)
public static bool operator >=(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is greater than or equal to the value ofright
; otherwise,false
.
operator !=(CellRange, CellRange)
Determines whether two specified CellRange objects have different values.
public static bool operator !=(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is different from the value ofright
; otherwise,false
.
operator <(CellRange, CellRange)
public static bool operator <(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is less than the value ofright
; otherwise,false
.
operator <=(CellRange, CellRange)
public static bool operator <=(CellRange left, CellRange right)
Parameters
Returns
- bool
true
if the value ofleft
is less than or equal to the value ofright
; otherwise,false
.