ExcelScript.RangeFont interface

This object represents the font attributes (font name, font size, color, etc.) for an object.

Remarks

Examples

/**
 * This script sets the font of A1 to Arial, size 16.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get A1 on the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Adjust the font settings for that cell.
  const cellFont = cell.getFormat().getFont();
  cellFont.setName("Arial");
  cellFont.setSize(16);
}

Methods

getBold()

Represents the bold status of the font.

getColor()

HTML color code representation of the text color (e.g., #FF0000 represents Red).

getItalic()

Specifies the italic status of the font.

getName()

Font name (e.g., "Calibri"). The name's length should not be greater than 31 characters.

getSize()

Font size.

getStrikethrough()

Specifies the strikethrough status of font. A null value indicates that the entire range doesn't have a uniform strikethrough setting.

getSubscript()

Specifies the subscript status of font. Returns true if all the fonts of the range are subscript. Returns false if all the fonts of the range are superscript or normal (neither superscript, nor subscript). Returns null otherwise.

getSuperscript()

Specifies the superscript status of font. Returns true if all the fonts of the range are superscript. Returns false if all the fonts of the range are subscript or normal (neither superscript, nor subscript). Returns null otherwise.

getTintAndShade()

Specifies a double that lightens or darkens a color for the range font. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the entire range doesn't have a uniform font tintAndShade setting.

getUnderline()

Type of underline applied to the font. See ExcelScript.RangeUnderlineStyle for details.

setBold(bold)

Represents the bold status of the font.

setColor(color)

HTML color code representation of the text color (e.g., #FF0000 represents Red).

setItalic(italic)

Specifies the italic status of the font.

setName(name)

Font name (e.g., "Calibri"). The name's length should not be greater than 31 characters.

setSize(size)

Font size.

setStrikethrough(strikethrough)

Specifies the strikethrough status of font. A null value indicates that the entire range doesn't have a uniform strikethrough setting.

setSubscript(subscript)

Specifies the subscript status of font. Returns true if all the fonts of the range are subscript. Returns false if all the fonts of the range are superscript or normal (neither superscript, nor subscript). Returns null otherwise.

setSuperscript(superscript)

Specifies the superscript status of font. Returns true if all the fonts of the range are superscript. Returns false if all the fonts of the range are subscript or normal (neither superscript, nor subscript). Returns null otherwise.

setTintAndShade(tintAndShade)

Specifies a double that lightens or darkens a color for the range font. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the entire range doesn't have a uniform font tintAndShade setting.

setUnderline(underline)

Type of underline applied to the font. See ExcelScript.RangeUnderlineStyle for details.

Method Details

getBold()

Represents the bold status of the font.

getBold(): boolean;

Returns

boolean

getColor()

HTML color code representation of the text color (e.g., #FF0000 represents Red).

getColor(): string;

Returns

string

getItalic()

Specifies the italic status of the font.

getItalic(): boolean;

Returns

boolean

getName()

Font name (e.g., "Calibri"). The name's length should not be greater than 31 characters.

getName(): string;

Returns

string

getSize()

Font size.

getSize(): number;

Returns

number

getStrikethrough()

Specifies the strikethrough status of font. A null value indicates that the entire range doesn't have a uniform strikethrough setting.

getStrikethrough(): boolean;

Returns

boolean

getSubscript()

Specifies the subscript status of font. Returns true if all the fonts of the range are subscript. Returns false if all the fonts of the range are superscript or normal (neither superscript, nor subscript). Returns null otherwise.

getSubscript(): boolean;

Returns

boolean

getSuperscript()

Specifies the superscript status of font. Returns true if all the fonts of the range are superscript. Returns false if all the fonts of the range are subscript or normal (neither superscript, nor subscript). Returns null otherwise.

getSuperscript(): boolean;

Returns

boolean

getTintAndShade()

Specifies a double that lightens or darkens a color for the range font. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the entire range doesn't have a uniform font tintAndShade setting.

getTintAndShade(): number;

Returns

number

getUnderline()

Type of underline applied to the font. See ExcelScript.RangeUnderlineStyle for details.

getUnderline(): RangeUnderlineStyle;

Returns

setBold(bold)

Represents the bold status of the font.

setBold(bold: boolean): void;

Parameters

bold

boolean

Returns

void

Examples

/**
 * This script bolds the text of cell A1.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get A1 on the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Bold the font for that cell
  cell.getFormat().getFont().setBold(true);
}

setColor(color)

HTML color code representation of the text color (e.g., #FF0000 represents Red).

setColor(color: string): void;

Parameters

color

string

Returns

void

setItalic(italic)

Specifies the italic status of the font.

setItalic(italic: boolean): void;

Parameters

italic

boolean

Returns

void

setName(name)

Font name (e.g., "Calibri"). The name's length should not be greater than 31 characters.

setName(name: string): void;

Parameters

name

string

Returns

void

Examples

/**
 * This script sets the font style of A1 to Arial.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get A1 on the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Adjust the font settings for that cell.
  cell.getFormat().getFont().setName("Arial");
}

setSize(size)

Font size.

setSize(size: number): void;

Parameters

size

number

Returns

void

Examples

/**
 * This script sets the font size of A1 to 16.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get A1 on the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Adjust the font settings for that cell.clear
  cell.getFormat().getFont().setSize(16);
}

setStrikethrough(strikethrough)

Specifies the strikethrough status of font. A null value indicates that the entire range doesn't have a uniform strikethrough setting.

setStrikethrough(strikethrough: boolean): void;

Parameters

strikethrough

boolean

Returns

void

setSubscript(subscript)

Specifies the subscript status of font. Returns true if all the fonts of the range are subscript. Returns false if all the fonts of the range are superscript or normal (neither superscript, nor subscript). Returns null otherwise.

setSubscript(subscript: boolean): void;

Parameters

subscript

boolean

Returns

void

setSuperscript(superscript)

Specifies the superscript status of font. Returns true if all the fonts of the range are superscript. Returns false if all the fonts of the range are subscript or normal (neither superscript, nor subscript). Returns null otherwise.

setSuperscript(superscript: boolean): void;

Parameters

superscript

boolean

Returns

void

setTintAndShade(tintAndShade)

Specifies a double that lightens or darkens a color for the range font. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the entire range doesn't have a uniform font tintAndShade setting.

setTintAndShade(tintAndShade: number): void;

Parameters

tintAndShade

number

Returns

void

setUnderline(underline)

Type of underline applied to the font. See ExcelScript.RangeUnderlineStyle for details.

setUnderline(underline: RangeUnderlineStyle): void;

Parameters

Returns

void