Interface ICellModel

Immutable representation of a cell within a sheet. Use

See

ISheetModel to set/update/clear cells.

interface ICellModel {
    asDate: Date;
    asText: string;
    asTextUnformatted: string;
    calcedValues: ICalcCellValues;
    colSpan: number;
    comments: string[];
    couldOverflow: boolean;
    formattedValue: ParsedNumberFormat;
    formula: string;
    hyperlink: IHyperlink;
    isCellModel: true;
    overflowAnchor: AnchorLocation;
    overflowSize: Size;
    renderHorizontalAlignment: HorizontalAlignment;
    rowSpan: number;
    style: ICellStyle;
    textFrame: ITextFrame;
    type: CellType;
    value: ICellValue;
    warnings: string[];
    bestFitSize(colWidth, fullContent?): Partial<Size>;
    cloneWithUpdate(update, calcedValues?): ICellModel;
    insets(): Rectangle;
    isContentful(): boolean;
    isEmpty(): boolean;
    isEqual(other): boolean;
    isReadOnly(): boolean;
    parseNumberFormat(numberFormat): ParsedNumberFormat;
}

Properties

asDate: Date

Will try to return the value as a javascript date.

asText: string

Will try to return the value as a displayable string

Remarks

This will have the numberFormatting applied.

See

asTextUnformatted

asTextUnformatted: string

Returns that values as an unformatted string. This is useful for copy/export. Note - Even in the case of unformatted text we do a 'minimum' amount. For example we convert dates, percentages, and times.

calcedValues: ICalcCellValues
colSpan: number

If the cell is merged then the colSpan will be greater than 1

comments: string[]

A list of comments. TODO - not implemented yet. This will be a proper comment type.

couldOverflow: boolean

If a cell can overflow.

Remarks

Currently only cells can overflow to the left or right.

formattedValue: ParsedNumberFormat

Returns the value as formatted text using

See

NumberFormatParser. This is the textValue as a string with additional rendering info from the NumberFormat formattedValue.displayText.

formula: string
hyperlink: IHyperlink

Hyperlink if set or null

isCellModel: true
overflowAnchor: AnchorLocation

This is used with overflowSize to calculate overflow.

See

overflowSize Only AnchorLocation.LEFT, AnchorLocation.CENTER, AnchorLocation.RIGHT are currently supported

overflowSize: Size

Used to calculate overflow. This is the entire size of the cell if there is overflow. If there is no overflow then this is null. This is slightly different than best fit in that it only measures offsetting insets

Remarks

This can be an expensive operations as it requires measuring the cell.

renderHorizontalAlignment: HorizontalAlignment

Returns the alignment to use when rendering the text. This is not just the style alignment because the type of cell can also influence

rowSpan: number

If the cell is merged then the rowSpan will be greater than 1

style: ICellStyle
textFrame: ITextFrame

Contains an ITextFrame. This can be null if this cell does not contain text. This is the final textFrame that includes the formattedValue as well as additional text layout information such as wrapping, alignment, etc. In addition rich text will be here

type: CellType
value: ICellValue

The value of the cell.

warnings: string[]

If the cell has warnings. Not this is different than an error as this will replace the value and type

Methods

  • Used to calculate the size that will best display the cell When calculating bestFit for rows or columns this will be used.

    If null is returned then this cell will be ignore for sizing purposes. Additionally either dimension can be null unspecified. Indicating that this direction will not be used.

    Parameters

    • colWidth: number

      The width of the column. Text uses this to wrap

    • Optional fullContent: boolean

    Returns Partial<Size>

    Default Value

    falseIf true then the cell will try to size with the minimum amount of space.
    
  • Used for creating padding around content. Note - insets do not effect fills or backgrounds

    Returns Rectangle

  • If a cell has a value. Note - If may or may not have styling or other characteristics. (for example row/col spans borders, etc)

    Returns boolean

  • If there is no value and a normal style

    Returns boolean

  • If the two cells are logically equal..

    Parameters

    Returns boolean

  • If the cell is readonly. This can can because the sheet is protected or locked or other.

    Returns boolean

  • Allows for parsing a number format for the current cell with with a different numberFormat.

    Parameters

    • numberFormat: string

    Returns ParsedNumberFormat