SheetXL - v1.0.2
    Preparing search index...

    Interface ICellStyle

    The ICellStyle interface combines user-applied styles with dynamic styles, such as those from tables or conditional formatting, to deliver the current appearance.

    interface ICellStyle {
        isICellStyle: true;
        clear(): ICellStyle;
        createStyle(update: ICellStyle.Update): ICellStyle;
        createTextFrame(text: string, allowWrap?: boolean): ITextFrame;
        getAlignment(): ITextBoxAlignment;
        getBestFit(): Partial<Size> | null;
        getBorders(): IBorders;
        getFill(): INone | ISolid | IGradient | IPattern;
        getFont(): IFontStyle;
        getInsets(): Rectangle;
        getNamed(): ICellStyle.INamed;
        getNumberFormat(): string;
        getProtection(): ICellProtection;
        getQuotePrefix(): boolean;
        hasVisibleStyling(): boolean;
        isNormal(): boolean;
        measureText(
            text: string,
            size?: number,
            family?: string,
            options?: MetricOptions,
        ): ExtendedMetrics;
        setAlignment(
            alignment: ITextBoxAlignment.Update,
            options?: UpdateOptions,
        ): ICellStyle;
        setBorders(borders: IBorders.Update, options?: UpdateOptions): ICellStyle;
        setFill(fill: IFill.Update, options?: UpdateOptions): ICellStyle;
        setFillGradient(options?: UpdateOptions): IGradient;
        setFillNone(options?: UpdateOptions): INone;
        setFillPattern(options?: UpdateOptions): IPattern;
        setFillSolid(options?: UpdateOptions): ISolid;
        setFont(
            font: string | IFontStyle | IFontStyle.Update<Serializable> | null,
            options?: UpdateOptions,
        ): ICellStyle;
        setNamed(
            named: string | ICellStyle.INamed | null,
            options?: UpdateOptions,
        ): ICellStyle;
        setNumberFormat(numFmt: string | null, options?: UpdateOptions): ICellStyle;
        setProtection(
            protection: ICellProtection.Update,
            options?: UpdateOptions,
        ): ICellStyle;
        setQuotePrefix(
            quotePrefix: boolean | null,
            options?: UpdateOptions,
        ): ICellStyle;
        toJSON(): ICellStyle.JSON | null;
        update(update: ICellStyle.Update, options?: UpdateOptions): ICellStyle;
    }

    Hierarchy (View Summary)

    Index
    isICellStyle: true

    For runtime type checking.

    • Clears all styling properties, resetting to default.

      Returns ICellStyle

      a reference to a normal style.

    • Creates a simple text frame that can be used for rendering and/or measuring.

      Parameters

      • text: string
      • OptionalallowWrap: boolean

        If true then will try to wrap on natural breaks.

      Returns ITextFrame

    • Returns the best fit size assuming no content.

      Returns Partial<Size> | null

    • Returns the insets content is laid out inside: Excel's, a quarter of the font's widest digit a side (2 px at Calibri 11) and 1 px above and below. Indent is not included because it depends on the alignment and the value's type.

      Returns Rectangle

    • Returns the protection format: whether the cell stays editable, and whether it shows its formula, while its sheet is protected.

      Returns ICellProtection

    • A boolean value indicating whether the text string in a cell should be prefixed by a single quote mark (e.g., 'text). In these cases, the quote is not stored in the Shared Strings Part.

      Returns boolean

    • This is used to determine if the style has rendering artifacts even if there is no content. (For example borders or background)

      Returns boolean

    • Returns true if the CellStyle is the normal style

      Returns boolean

    • Measure the text using the styling properties

      Parameters

      • text: string

        The text to measure.

      • Optionalsize: number

        Size

      • Optionalfamily: string

        Family

      • Optionaloptions: MetricOptions

        Options for the measurement.

      Returns ExtendedMetrics

      The vertical metrics are a cell's line: lineHeight is the height of a row sized to one line of this text, which leaves room around the font's ascent and descent as Excel does.

      'to the cell font.size'
      
      'to the cell font.family'
      
    • Sets the borders.

      This method allows updating borders using an IBorders or a shorthand property object.

      Parameters

      • borders: IBorders.Update

        The borders object or a shorthand property object to apply. Pass null to clear.

      • Optionaloptions: UpdateOptions

        Optional configuration for the update.

      Returns ICellStyle

      The IBorders object for further modifications.