Represents a string with mixed formatting in a cell or cell comment.

The formatting of the string is controlled in a similar fashion as it would be in Microsoft Excel. In Excel, the user must select a portion of the text and set the various formatting properties of that selected text.

With the FormattedString, a portion of the string is "selected" by calling either GetFont(int) or GetFont(int,int). Formatting properties are then set on the returned [[FormattedStringFont]] and all characters in the font's selection range are given these properties.

Getting the formatting properties of a [[FormattedStringFont]] will return the formatting of the first character in font's selection range. This is similar to Excel, which will update the formatting interface to reflect the formatting of the first character in a selection range when a cell's text is selected.

Hierarchy

Hierarchy

  • Base
    • FormattedString

Implements

  • IWorksheetCellOwnedValue
  • IComparable$1<FormattedString>
  • IFormattedString
  • IFormattedItem
  • IChangeInfoContext

Constructors

  • Parameters

    • workbook: Workbook
    • element: StringElement

    Returns FormattedString

  • Parameters

    • workbook: Workbook
    • element: StringElement
    • isElementInCache: boolean
    • addElementToCache: boolean

    Returns FormattedString

  • Parameters

    • unformattedString: string

    Returns FormattedString

  • Parameters

    • Rest ..._rest: any[]

    Returns FormattedString

Properties

$type: Type
$t: Type
nextHashCode: number

Accessors

  • get unformattedString(): string
  • Gets or sets the unformatted string.

    If the new unformatted string assigned is shorter than the old unformatted string, all formatting outside the range of the new value will be lost.

    The unformatted string.

    Throws

    [[ArgumentNullException]] The value assigned is a null string.

    Returns string

  • set unformattedString(a): void
  • Parameters

    • a: string

    Returns void

Methods

  • Creates a new [[FormattedString]] that is a copy of this one.

    This should be used if the same formatted string needs to be used in multiple cells. The FormattedString class can only exist as the [[WorksheetCell.value]] of one cell at a time. If the FormattedString is already the value of a cell, and needs to be set as the value of another cell, clone the FormattedString and set the returned clone as value of the cell.

    The cloned FormattedString only takes its original configuration for this instance. If this instance is cloned and than changed, the clone will not be changed as well; it will remain as it was when it was cloned.

    Returns FormattedString

  • Determines whether the specified [[Object]] is equal to this [[FormattedString]].

    Parameters

    • obj: any

      The value to test for equality to this FormattedString.

    Returns boolean

  • Gets the font which controls the formatting properties in the string from the specified start index to the end of the string.

    If the start index is greater than or equal to the length of the unformatted string, no exception will be thrown. It will be thrown later when one of the formatting properties of the returned [[FormattedStringFont]] is set.

    Throws

    [[ArgumentOutOfRangeException]] 'startIndex' is less than zero.

    Parameters

    • startIndex: number

      The index of the first character the returned font controls.

    Returns FormattedStringFont

  • Gets the font which controls the formatting properties in the string from the specified start index for the specified number of characters.

    If the start index is greater than or equal to the length of the unformatted string, no exception will be thrown. It will be thrown later when one of the formatting properties of the returned [[FormattedStringFont]] is set.

    Throws

    [[ArgumentOutOfRangeException]] 'startIndex' is less than zero.

    Throws

    [[ArgumentOutOfRangeException]] 'length' is less than one. A zero length string cannot be controlled by a formatting font.

    Parameters

    • startIndex: number

      The index of the first character the returned font controls.

    • length: number

      The number of characters after the start index controlled by the returned font.

    Returns FormattedStringFont

  • Calculates the has code for this [[FormattedString]].

    Returns number

  • Returns Base

  • Returns the [[String]] that represents this [[FormattedString]]. This is just the unformatted string.

    This will return the same value as [[unformattedString]].

    Returns string

  • 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[]

  • Parameters

    • obj: any

    Returns number

  • Parameters

    • a: any
    • b: any

    Returns boolean