Table of Contents

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 bool

Indicates whether the starting column is fixed.

startingRow int?

The starting row of the cell range.

fixedStartingRow bool

Indicates whether the starting row is fixed.

endingColumn int?

The ending column of the cell range.

fixedEndingColumn bool

Indicates whether the ending column is fixed.

endingRow int?

The ending row of the cell range.

fixedEndingRow bool

Indicates whether the ending row is fixed.

sheetname string

The 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. This creates a single cell range

public CellRange(int? column, bool fixedColumn, int? row, bool fixedRow, string sheetname)

Parameters

column int?

The column of the cell range.

fixedColumn bool

Indicates whether the column is fixed.

row int?

The row of the cell range.

fixedRow bool

Indicates whether the row is fixed.

sheetname string

The 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 string

The 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. This creates a single cell range

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 string

The 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 string

The 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

bool

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

bool

Height

Gets the height of the cell range.

public int Height { get; }

Property Value

int

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

bool

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

bool

Width

Gets the width of the cell range.

public int Width { get; }

Property Value

int

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

other CellRange

The CellRange to compare with the current instance.

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.

Equals(CellRange)

Determines whether the specified CellRange is equal to the current CellRange instance.

public virtual bool Equals(CellRange other)

Parameters

other CellRange

The CellRange to compare with the current instance.

Returns

bool

True if the specified CellRange is equal to the current instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current CellRange instance.

public override bool Equals(object obj)

Parameters

obj object

The 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)

Determines whether the current CellRange overlaps with another specified CellRange.

public bool RangeOverlaps(CellRange other)

Parameters

other CellRange

The CellRange to compare with the current CellRange.

Returns

bool

true if the current CellRange overlaps with the other CellRange; otherwise, false.

Exceptions

ArgumentNullException

other is null.

Operators

operator ==(CellRange, CellRange)

Determines whether two specified CellRange objects have the same value.

public static bool operator ==(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is the same as the value of right; otherwise, false.

operator >(CellRange, CellRange)

Determines whether one specified CellRange is greater than another specified CellRange.

public static bool operator >(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is greater than the value of right; otherwise, false.

operator >=(CellRange, CellRange)

Determines whether one specified CellRange is greater than or equal to another specified CellRange.

public static bool operator >=(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is greater than or equal to the value of right; otherwise, false.

operator !=(CellRange, CellRange)

Determines whether two specified CellRange objects have different values.

public static bool operator !=(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is different from the value of right; otherwise, false.

operator <(CellRange, CellRange)

Determines whether one specified CellRange is less than another specified CellRange.

public static bool operator <(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is less than the value of right; otherwise, false.

operator <=(CellRange, CellRange)

Determines whether one specified CellRange is less than or equal to another specified CellRange.

public static bool operator <=(CellRange left, CellRange right)

Parameters

left CellRange

The first CellRange to compare.

right CellRange

The second CellRange to compare.

Returns

bool

true if the value of left is less than or equal to the value of right; otherwise, false.