Represents a cell in a Microsoft Excel worksheet.

Hierarchy

Hierarchy

  • Base
    • WorksheetCell

Implements

  • ICellFormatOwner
  • IComparable$1<WorksheetCell>
  • IFormattedStringOwner

Constructors

  • Parameters

    Returns WorksheetCell

Properties

$type: Type
$t: Type
nextHashCode: number

Accessors

  • get associatedDataTable(): WorksheetDataTable
  • Gets the data table to which the cell belongs.

    The cells in the left-most column and top-most row of the data table will return null for the associated data table.

    If a data table is associated with the cell, getting the [[value]] will return the calculated value for the cell.

    Note: it is slightly faster to use the [[WorksheetRow.getCellAssociatedDataTable]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellAssociatedDataTable method.

    The data table to which the cell belongs or null if the cell does not belong to a data table.

    See

    • [[Worksheet.dataTables]]
    • [[WorksheetDataTableCollection.add]]
    • [[WorksheetRow.getCellAssociatedDataTable]]

    Returns WorksheetDataTable

  • get associatedMergedCellsRegion(): WorksheetMergedCellsRegion
  • Gets the merged cells region which contains the cell, or null if the cell is not merged.

    Note: it is slightly faster to use the [[WorksheetRow.getCellAssociatedMergedCellsRegion]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellAssociatedMergedCellsRegion method.

    The merged cells region which contains the cell, or null if the cell is not merged.

    See

    [[WorksheetRow.getCellAssociatedMergedCellsRegion]]

    Returns WorksheetMergedCellsRegion

  • get associatedTable(): WorksheetTable
  • Gets the [[WorksheetTable]] to which this cell belongs.

    A cell belongs to a table if it exists in any area of the table. It can be a header cell, total cell, or a cell in the data area.

    Note: it is slightly faster to use the [[WorksheetRow.getCellAssociatedTable]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellAssociatedTable method.

    See

    • [[WorksheetTable]]
    • [[Worksheet.tables]]

    Returns WorksheetTable

  • get cellFormat(): IWorksheetCellFormat
  • Gets the cell formatting for this cell.

    Use this property to set cell formatting specific to the cell. If you will be applying the format to numerous cells, see the [[Workbook.createNewWorksheetCellFormat]] method for performance considerations.

    If this cell belongs to a merged cell region, getting the CellFormat will get the CellFormat of the associated merged cell region.

    Note: it is slightly faster to use the [[WorksheetRow.getCellFormat]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellFormat method.

    The cell formatting for this cell.

    See

    • [[getResolvedCellFormat]]
    • [[WorksheetRow.getCellFormat]]

    Returns IWorksheetCellFormat

  • get columnIndex(): number
  • Gets the column index of the cell. The column index of the cell.

    Returns number

  • get comment(): WorksheetCellComment
  • Gets or sets the comment applied to the cell.

    Note: it is slightly faster to use the [[WorksheetRow.getCellComment]] or [[WorksheetRow.setCellComment]] methods, which do not create [[WorksheetCell]] instances internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellComment or WorksheetRow.SetCellComment methods.

    The comment applied to the cell.

    Throws

    [[InvalidOperationException]] The value applied only has only one anchor cell set. It should have both or neither anchor cells set.

    Throws

    [[InvalidOperationException]] The value has its [[WorksheetShape.topLeftCornerCell]] and [[WorksheetShape.bottomRightCornerCell]] anchors set but they are from different worksheets.

    See

    • [[WorksheetRow.getCellComment]]
    • [[WorksheetRow.setCellComment]]

    Returns WorksheetCellComment

  • set comment(a): void
  • Parameters

    Returns void

  • get dataValidationRule(): DataValidationRule
  • Gets or sets the data validation rule for the [[WorksheetCell]].

    Throws

    [[ArgumentException]] Occurs when the value specified is already applied to cells in another worksheet.

    Throws

    [[ArgumentException]] Occurs when the value specified is invalid based on its rule type's requirements.

    See

    • [[Worksheet.dataValidationRules]]
    • [[AnyValueDataValidationRule]]
    • [[ListDataValidationRule]]
    • [[CustomDataValidationRule]]
    • [[OneConstraintDataValidationRule]]
    • [[TwoConstraintDataValidationRule]]

    Returns DataValidationRule

  • set dataValidationRule(a): void
  • Parameters

    Returns void

  • get formula(): Formula
  • Gets the formula which has been applied to the cell.

    If a formula has been applied to the cell, getting the [[value]] will return the calculated value of the formula.

    Note: it is slightly faster to use the [[WorksheetRow.getCellFormula]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellFormula method.

    The formula which has been applied to the cell or null if no formula has been applied.

    See

    • [[Formula.applyTo]]
    • [[Formula.applyTo]]
    • [[Formula.applyTo]]
    • [[applyFormula]]
    • [[WorksheetRegion.applyFormula]]
    • [[WorksheetRegion.applyArrayFormula]]
    • [[WorksheetRow.getCellFormula]]

    Returns Formula

  • get hasCellFormat(): boolean
  • Gets the value which indicates whether the cell's format has been initialized yet.

    See

    [[cellFormat]]

    Returns boolean

  • get hasComment(): boolean
  • Get the value indicating whether the cell has an associated comment.

    Note: it is slightly faster to use the [[WorksheetRow.getCellComment]] method and check for a non null return value, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellComment method and checking for a non null return value.

    True if the cell has an associated comment; False otherwise.

    See

    • [[comment]]
    • [[WorksheetRow.getCellComment]]

    Returns boolean

  • get rowIndex(): number
  • Gets the row index of the cell. The row index of the cell.

    Returns number

  • get value(): any
  • Gets or sets the value of the cell.

    If this cell belongs to a merged cell region and it is the top-left cell of the region, getting and setting the value will get and set the value of the associated merged cell region. Getting the value of other cells in a merged cell region will always return null. Setting the value of other cells in a merged cell region will have no effect.

    If a formula has been applied to the cell or a data table is associated with the cell, getting the Value will return the calculated value of the cell.

    The types supported for the value are:

    • System.Byte
    • System.SByte
    • System.Int16
    • System.Int64
    • System.UInt16
    • System.UInt64
    • System.UInt32
    • System.Int32
    • System.Single
    • System.Double
    • System.Boolean
    • System.Char
    • System.Enum
    • System.Decimal
    • System.DateTime
    • System.String
    • System.Text.StringBuilder
    • System.DBNull
    • [[ErrorValue]]
    • [[FormattedString]]

    Note: it is slightly faster to use the [[WorksheetRow.getCellValue]] or [[WorksheetRow.setCellValue]] methods, which do not create [[WorksheetCell]] instances internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetCellComment or WorksheetRow.SetCellComment methods.

    The value of the cell.

    Throws

    [[NotSupportedException]] The assigned value's type is not supported and can't be exported to Excel.

    Throws

    [[InvalidOperationException]] The value assigned is a [[formula]]. Instead, [[Formula.applyTo]] should be called on the Formula, passing in the cell.

    Throws

    [[InvalidOperationException]] The value assigned is a [[WorksheetDataTable]]. Instead, the [[WorksheetDataTable.cellsInTable]] should be set to a region containing the cell.

    Throws

    [[InvalidOperationException]] The value assigned is a FormattedString which is the value another cell or merged cell region.

    Throws

    [[InvalidOperationException]] The value is assigned and this cell is part of an [[ArrayFormula]] or WorksheetDataTable.

    See

    • [[associatedMergedCellsRegion]]
    • [[WorksheetCell.isCellTypeSupported]]
    • [[WorksheetMergedCellsRegion.value]]
    • [[formula]]
    • [[associatedDataTable]]
    • [[WorksheetRow.getCellValue]]
    • [[WorksheetRow.setCellValue]]

    Returns any

  • set value(a): void
  • Parameters

    • a: any

    Returns void

  • get worksheet(): Worksheet
  • Gets the worksheet to which the cell belongs. The worksheet to which the cell belongs.

    Returns Worksheet

Methods

  • Applies a formula to the cell.

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

    Note: it is slightly faster to use the [[WorksheetRow.applyCellFormula]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.ApplyCellFormula method.

    Throws

    [[ArgumentNullException]] 'value' is null or empty.

    Throws

    [[FormulaParseException]] 'value' is not a valid formula.

    Throws

    [[InvalidOperationException]] The cell is part of an array formula or data table which is not confined to just the cell.

    See

    • [[formula]]
    • [[WorksheetRow.applyCellFormula]]

    Parameters

    • value: string

      The formula to parse and apply to the cell.

    Returns void

  • Removes the comment associated with the cell.

    Note: it is slightly faster to use the [[WorksheetRow.setCellComment]] method and pass in null as the comment parameter, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.SetCellComment method and passing in null as the comment parameter.

    See

    • [[comment]]
    • [[hasComment]]
    • [[WorksheetRow.setCellComment]]

    Returns void

  • Determines whether the specified object is another [[WorksheetCell]] instance which refers to the same location on the same worksheet as this cell.

    Parameters

    • obj: any

      The instance to check for equality.

    Returns boolean

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

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

    Note: it is slightly faster to use the [[WorksheetRow.getCellBoundsInTwips]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.GetBoundsInTwips method.

    See

    [[WorksheetRow.getCellBoundsInTwips]]

    Returns IgRect

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

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

    Note: it is slightly faster to use the [[WorksheetRow.getCellBoundsInTwips]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.GetBoundsInTwips method.

    See

    [[WorksheetRow.getCellBoundsInTwips]]

    Parameters

    Returns IgRect

  • Gets the hash code of the [[WorksheetCell]].

    Returns number

  • Gets the effective hyperlink on the cell.

    If multiple hyperlinks are applied to the cell, the last one in the [[Worksheet.hyperlinks]] collection will be used.

    If the cell has one or more hyperlinks in the [[Worksheet.hyperlinks]] collection as well as a formula containing a HYPERLINK function, the last hyperlink from the collection will be used.

    If the cell has a hyperlink due to the HYPERLINK function being used in a formula, the returned value will be sealed.

    See

    • [[Worksheet.hyperlinks]]
    • [[WorksheetHyperlink]]
    • [[WorksheetHyperlink.isSealed]]

    Returns WorksheetHyperlink

  • Gets the resolved cell formatting for this cell.

    If any cell format properties are the default values on the cell, the values from the owning row's cell format will be used. If those are default, then the values from the owning column's cell format will be used. Otherwise, the workbook default values will be used.

    Note: it is slightly faster to use the [[WorksheetRow.getResolvedCellFormat]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this method is equivalent to using the WorksheetRow.GetResolvedCellFormat method.

    See

    • [[cellFormat]]
    • [[RowColumnBase.cellFormat]]
    • [[WorksheetRow.getResolvedCellFormat]]

    Returns IWorksheetCellFormat

  • Gets the text displayed in the cell.

    The display text is based on the value of the cell and the format string applied to the cell.

    Note: it is slightly faster to use the [[WorksheetRow.getCellText]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetText method.

    See

    • [[value]]
    • [[IWorksheetCellFormat.formatString]]

    Returns string

  • Gets the text of the cell.

    The text is based on the value of the cell and the format string applied to the cell.

    Note: it is slightly faster to use the [[WorksheetRow.getCellText]] method, which does not create a [[WorksheetCell]] instance internally. However, if a reference to the WorksheetCell instance already exists, using this property is equivalent to using the WorksheetRow.GetText method.

    Throws

    [[InvalidEnumArgumentException]] 'textFormatMode' is not defined in the [[TextFormatMode]] enumeration.

    See

    • [[value]]
    • [[IWorksheetCellFormat.formatString]]

    Parameters

    • textFormatMode: TextFormatMode

      The format mode to use when getting the cell text.

    Returns string

  • Returns Base

  • Gets the string representation of the address of the cell.

    Returns string

  • Gets the string representation of the address of the cell.

    Parameters

    • cellReferenceMode: CellReferenceMode

      The mode used to generate cell references.

    • includeWorksheetName: boolean

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

    Returns string

  • Gets the string representation of the address of the cell.

    Parameters

    • cellReferenceMode: CellReferenceMode

      The mode used to generate cell references.

    • includeWorksheetName: boolean

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

    • useRelativeColumn: boolean

      The value indicating whether to use a relative column address.

    • useRelativeRow: boolean

      The value indicating whether to use a relative row address.

    Returns string

  • Returns a boolean indicating if the value of the cell is valid considering the associated [[dataValidationRule]]

    See

    • [[value]]
    • [[dataValidationRule]]
    • [[Worksheet.dataValidationRules]]

    Returns boolean

  • Parameters

    • item1: any
    • item2: any

    Returns number

  • Parameters

    • item1: any
    • item2: any

    Returns number

  • Parameters

    • item1: any
    • item2: any

    Returns boolean

  • Parameters

    • a: any
    • b: any

    Returns boolean

  • Parameters

    • obj: any

    Returns any[]

  • Parameters

    • obj: any

    Returns any[]

  • Gets the string representation of the address of the cell.

    Parameters

    • worksheetRow: WorksheetRow

      The WorksheetRow of the cell.

    • columnIndex: number

      The index of the column of the cell.

    • cellReferenceMode: CellReferenceMode

      The mode used to generate cell references.

    • includeWorksheetName: boolean

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

    Returns string

  • Gets the string representation of the address of the cell.

    Parameters

    • worksheetRow: WorksheetRow

      The WorksheetRow of the cell.

    • columnIndex: number

      The index of the column of the cell.

    • cellReferenceMode: CellReferenceMode

      The mode used to generate cell references.

    • includeWorksheetName: boolean

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

    • useRelativeColumn: boolean

      The value indicating whether to use a relative column address.

    • useRelativeRow: boolean

      The value indicating whether to use a relative row address.

    Returns string

  • Parameters

    • obj: any

    Returns number

  • Returns True if a particular type of value can be exported to excel.

    Throws

    [[ArgumentNullException]] 'cellType' is null.

    Parameters

    • cellType: Type

      The type to test.

    Returns boolean

  • Parameters

    • a: any
    • b: any

    Returns boolean