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
startingColumnint?The starting column of the cell range.
fixedStartingColumnboolIndicates whether the starting column is fixed.
startingRowint?The starting row of the cell range.
fixedStartingRowboolIndicates whether the starting row is fixed.
endingColumnint?The ending column of the cell range.
fixedEndingColumnboolIndicates whether the ending column is fixed.
endingRowint?The ending row of the cell range.
fixedEndingRowboolIndicates whether the ending row is fixed.
sheetnamestringThe 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
columnint?The column of the cell range.
fixedColumnboolIndicates whether the column is fixed.
rowint?The row of the cell range.
fixedRowboolIndicates whether the row is fixed.
sheetnamestringThe 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
startingColumnint?The starting column of the cell range.
startingRowint?The starting row of the cell range.
endingColumnint?The ending column of the cell range.
endingRowint?The ending row of the cell range.
sheetnamestringThe 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
columnint?The column of the cell range.
rowint?The row of the cell range.
sheetnamestringThe 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
rangestringThe range string to initialize the cell range.
Exceptions
- ArgumentNullException
If
rangeis null- ArgumentOutOfRangeException
Thrown when any of the column or row values are less than 1.
- InvalidRangeException
Thrown when the
rangedoes 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
otherin the sort order. - Zero: This instance occurs in the same position in the sort order as
other. - Greater than zero: This instance follows
otherin 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
objobjectThe 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
otherisnull.
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
trueif the value ofleftis the same as the value ofright; otherwise,false.
operator >(CellRange, CellRange)
public static bool operator >(CellRange left, CellRange right)
Parameters
Returns
- bool
trueif the value ofleftis greater than the value ofright; otherwise,false.
operator >=(CellRange, CellRange)
public static bool operator >=(CellRange left, CellRange right)
Parameters
Returns
- bool
trueif the value ofleftis 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
trueif the value ofleftis different from the value ofright; otherwise,false.
operator <(CellRange, CellRange)
public static bool operator <(CellRange left, CellRange right)
Parameters
Returns
- bool
trueif the value ofleftis less than the value ofright; otherwise,false.
operator <=(CellRange, CellRange)
public static bool operator <=(CellRange left, CellRange right)
Parameters
Returns
- bool
trueif the value ofleftis less than or equal to the value ofright; otherwise,false.