Show / Hide Table of Contents

Class WorksheetRegion

Represents a rectangular region of cells on a worksheet.

Inheritance
System.Object
WorksheetRegion
WorksheetMergedCellsRegion
Implements
System.Collections.Generic.IEnumerable<WorksheetCell>
System.Collections.IEnumerable
Namespace: Infragistics.Documents.Excel
Assembly: IgniteUI.Blazor.Documents.Excel.dll
Syntax
public class WorksheetRegion : Object, IEnumerable<WorksheetCell>, IEnumerable

Constructors

WorksheetRegion(Worksheet, Int32, Int32, Int32, Int32)

Initializes a new instance of the WorksheetRegion class.

Declaration
public WorksheetRegion(Worksheet worksheet, int firstRow, int firstColumn, int lastRow, int lastColumn)
Parameters
Type Name Description
Worksheet worksheet

The worksheet on which the region resides.

System.Int32 firstRow

The index of the first row of the region.

System.Int32 firstColumn

The index of the first column of the region.

System.Int32 lastRow

The index of the last row of the region.

System.Int32 lastColumn

The index of the last row column of the region.

Exceptions
Type Condition
System.ArgumentNullException

worksheet is null.

System.InvalidOperationException

firstRow is greater than lastRow or firstColumn is greater than lastColumn.

System.ArgumentOutOfRangeException

Any row or column indices specified are outside the valid row or column ranges.

Properties

FirstColumn

Gets the index of the first column in the region.

Declaration
public int FirstColumn { get; }
Property Value
Type Description
System.Int32

The index of the first column in the region.

FirstRow

Gets the index of the first row in the region.

Declaration
public int FirstRow { get; }
Property Value
Type Description
System.Int32

The index of the first row in the region.

LastColumn

Gets the index of the last column in the region.

Declaration
public int LastColumn { get; }
Property Value
Type Description
System.Int32

The index of the last column in the region.

LastRow

Gets the index of the last row in the region.

Declaration
public int LastRow { get; }
Property Value
Type Description
System.Int32

The index of the last row in the region.

Worksheet

Gets the worksheet on which the region resides.

Declaration
public Worksheet Worksheet { get; }
Property Value
Type Description
Worksheet

The worksheet on which the region resides or null if the region has been shifted off the worksheet.

Methods

ApplyArrayFormula(String)

Applies a array formula to the region of cells.

Declaration
public void ApplyArrayFormula(string value)
Parameters
Type Name Description
System.String value

The array formula to parse and apply to the region.

Remarks

value is parsed based on the CellReferenceMode of the Workbook to which the region belongs. If the region's Worksheet has been removed from its parent collection, the A1 CellReferenceMode will be used to parse the formula.

Exceptions
Type Condition
System.ArgumentNullException

value is null or empty.

FormulaParseException

value is not a valid formula.

System.InvalidOperationException

The region contains another array formula or data table which extends outside the region.

See Also
ArrayFormula

ApplyFormula(String)

Applies a formula to the region of cells.

Declaration
public void ApplyFormula(string value)
Parameters
Type Name Description
System.String value

The formula to parse and apply to the region.

Remarks

value is parsed based on the CellReferenceMode of the Workbook to which the region belongs. If the region's Worksheet has been removed from its parent collection, the A1 CellReferenceMode will be used to parse the formula.

Exceptions
Type Condition
System.ArgumentNullException

value is null or empty.

FormulaParseException

value is not a valid formula.

System.InvalidOperationException

The region contains an array formula or data table which extends outside the region.

See Also
Formula

Equals(Object)

Determines whether the specified value equals this WorksheetRegion.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The value to test for equality.

Returns
Type Description
System.Boolean

FormatAsTable(Boolean)

Formats the region as a table and adds an associated WorksheetTable to the Tables collection.

Declaration
public WorksheetTable FormatAsTable(bool tableHasHeaders)
Parameters
Type Name Description
System.Boolean tableHasHeaders

A value which indicates whether the top row of the region contains the headers for the table.

Returns
Type Description
WorksheetTable

The WorksheetTable created the represent the formatted table for the region.

Remarks

When the table is created, the DefaultTableStyle will be applied to the Style value.

When the table is created, the column names will be taken from the cells in the header row if tableHasHeaders is True. If it is False, the column names will be generated and the cells for the header row will be inserted into the worksheet.

The column names are unique within the owning WorksheetTable. If, when the table is created, there are two or more columns with the same name, the second and subsequent duplicate column names will have a number appended to make them unique. If any cells in the header row have a non-string value, their value will be changed to a string (the current display text of the cell). If any cells in the header row have no value, they will be given a generated column name.

If the region partially contains any merged cell regions, they will be removed from the worksheet and the table region will be expanded to include all cells from the merged region.

Exceptions
Type Condition
System.InvalidOperationException

The region contains one or more cells from another WorksheetTable.

System.InvalidOperationException

The region contains one or more cells which have a multi-cell ArrayFormula applied.

System.InvalidOperationException

The region contains one or more cells which are part of a WorksheetDataTable.

See Also
WorksheetTable
Tables
Name
IsHeaderRowVisible
Add(String, Boolean, WorksheetTableStyle)

FormatAsTable(Boolean, WorksheetTableStyle)

Formats the region as a table and adds an associated WorksheetTable to the Tables collection.

Declaration
public WorksheetTable FormatAsTable(bool tableHasHeaders, WorksheetTableStyle tableStyle)
Parameters
Type Name Description
System.Boolean tableHasHeaders

A value which indicates whether the top row of the region contains the headers for the table.

WorksheetTableStyle tableStyle

The WorksheetTableStyle to apply to the table or null to use the DefaultTableStyle.

Returns
Type Description
WorksheetTable

The WorksheetTable created the represent the formatted table for the region.

Remarks

When the table is created, the specified tableStyle will be applied to the Style value.

When the table is created, the column names will be taken from the cells in the header row if tableHasHeaders is True. If it is False, the column names will be generated and the cells for the header row will be inserted into the worksheet.

The column names are unique within the owning WorksheetTable. If, when the table is created, there are two or more columns with the same name, the second and subsequent duplicate column names will have a number appended to make them unique. If any cells in the header row have a non-string value, their value will be changed to a string (the current display text of the cell). If any cells in the header row have no value, they will be given a generated column name.

If the region partially contains any merged cell regions, they will be removed from the worksheet and the table region will be expanded to include all cells from the merged region.

Exceptions
Type Condition
System.ArgumentException

The specified tableStyle does not exist in the CustomTableStyles or StandardTableStyles collections.

System.InvalidOperationException

The region contains one or more cells from another WorksheetTable.

System.InvalidOperationException

The region contains one or more cells which have a multi-cell ArrayFormula applied.

System.InvalidOperationException

The region contains one or more cells which are part of a WorksheetDataTable.

See Also
WorksheetTable
Tables
Name
CustomTableStyles
StandardTableStyles
Style
IsHeaderRowVisible
Add(String, Boolean, WorksheetTableStyle)

GetBoundsInTwips()

Gets the bounds of the region in twips (1/20th of a point).

Declaration
public Rect GetBoundsInTwips()
Returns
Type Description
Rect

The bounds of the region on its worksheet.

Remarks

The bounds returned by this method are only valid with the current configuration of the worksheet. If any rows or columns before the region are resized, these bounds will no longer reflect the position of the region.

GetBoundsInTwips(PositioningOptions)

Gets the bounds of the region in twips (1/20th of a point).

Declaration
public Rect GetBoundsInTwips(PositioningOptions options)
Parameters
Type Name Description
PositioningOptions options

The options to use when getting the bounds of the region.

Returns
Type Description
Rect

The bounds of the region on its worksheet.

Remarks

The bounds returned by this method are only valid with the current configuration of the worksheet. If any rows or columns before the region are resized, these bounds will no longer reflect the position of the region.

GetHashCode()

Gtes the hash code for the WorksheetRegion.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

ToString()

Gets the string representation of the range of cells in the region.

Declaration
public override string ToString()
Returns
Type Description
System.String

The string representation of the range of cells in the region.

ToString(CellReferenceMode, Boolean)

Gets the string representation of the range of cells in the region.

Declaration
public string ToString(CellReferenceMode cellReferenceMode, bool includeWorksheetName)
Parameters
Type Name Description
CellReferenceMode cellReferenceMode

The mode used to generate cell references.

System.Boolean includeWorksheetName

The value indicating whether to include the worksheet name in the range address.

Returns
Type Description
System.String

The string representation of the range of cells in the region.

ToString(CellReferenceMode, Boolean, Boolean, Boolean)

Gets the string representation of the range of cells in the region.

Declaration
public string ToString(CellReferenceMode cellReferenceMode, bool includeWorksheetName, bool useRelativeColumn, bool useRelativeRow)
Parameters
Type Name Description
CellReferenceMode cellReferenceMode

The mode used to generate cell references.

System.Boolean includeWorksheetName

The value indicating whether to include the worksheet name in the range address.

System.Boolean useRelativeColumn

The value indicating whether to use a relative column address for the cells in the range.

System.Boolean useRelativeRow

The value indicating whether to use a relative row address for the cells in the range.

Returns
Type Description
System.String

The string representation of the range of cells in the region.

Implements

System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable