Font

Font class

Encapsulates the font object used in a spreadsheet.

class Font;

Example

const { Workbook, Color } = require("aspose.cells.node");

//Instantiating a Workbook object
var workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var worksheet = workbook.worksheets.get(0);
//Accessing the "A1" cell from the worksheet
var cell = worksheet.cells.get("A1");
//Adding some value to the "A1" cell
cell.putValue("Hello Aspose!");
var style = cell.getStyle();
var font = style.font;
//Setting the font name to "Times New Roman"
font.setName("Times New Roman");
//Setting font size to 14
font.setSize(14);
//setting font color as Red
font.color = Color.Red;
cell.setStyle(style);
//Saving the Excel file
workbook.save("output/Font.xls");

Properties

PropertyTypeDescription
charsetnumberRepresent the character set.
isItalicbooleanGets or sets a value indicating whether the font is italic.
isBoldbooleanGets or sets a value indicating whether the font is bold.
capsTypeTextCapsTypeGets and sets the text caps type.
strikeTypeTextStrikeTypeGets the strike type of the text.
isStrikeoutbooleanGets or sets a value indicating whether the font is single strikeout.
scriptOffsetnumberGets and sets the script offset,in unit of percentage
isSuperscriptbooleanGets or sets a value indicating whether the font is super script.
isSubscriptbooleanGets or sets a value indicating whether the font is subscript.
underlineFontUnderlineTypeGets or sets the font underline type.
doubleSizenumberGets and sets the double size of the font.
sizenumberGets or sets the size of the font.
themeColorThemeColorGets and sets the theme color.
colorColorGets or sets the Color of the font.
argbColornumberGets and sets the color with a 32-bit ARGB value.
isNormalizeHeightsbooleanIndicates whether the normalization of height that is to be applied to the text run.
schemeTypeFontSchemeTypeGets and sets the scheme type of the font.

Methods

MethodDescription
getCharset()@deprecated. Please use the ‘charset’ property instead. Represent the character set.
setCharset(number)@deprecated. Please use the ‘charset’ property instead. Represent the character set.
isItalic()@deprecated. Please use the ‘isItalic’ property instead. Gets or sets a value indicating whether the font is italic.
setIsItalic(boolean)@deprecated. Please use the ‘isItalic’ property instead. Gets or sets a value indicating whether the font is italic.
isBold()@deprecated. Please use the ‘isBold’ property instead. Gets or sets a value indicating whether the font is bold.
setIsBold(boolean)@deprecated. Please use the ‘isBold’ property instead. Gets or sets a value indicating whether the font is bold.
getCapsType()@deprecated. Please use the ‘capsType’ property instead. Gets and sets the text caps type.
setCapsType(TextCapsType)@deprecated. Please use the ‘capsType’ property instead. Gets and sets the text caps type.
getStrikeType()@deprecated. Please use the ‘strikeType’ property instead. Gets the strike type of the text.
setStrikeType(TextStrikeType)@deprecated. Please use the ‘strikeType’ property instead. Gets the strike type of the text.
isStrikeout()@deprecated. Please use the ‘isStrikeout’ property instead. Gets or sets a value indicating whether the font is single strikeout.
setIsStrikeout(boolean)@deprecated. Please use the ‘isStrikeout’ property instead. Gets or sets a value indicating whether the font is single strikeout.
getScriptOffset()@deprecated. Please use the ‘scriptOffset’ property instead. Gets and sets the script offset,in unit of percentage
setScriptOffset(number)@deprecated. Please use the ‘scriptOffset’ property instead. Gets and sets the script offset,in unit of percentage
isSuperscript()@deprecated. Please use the ‘isSuperscript’ property instead. Gets or sets a value indicating whether the font is super script.
setIsSuperscript(boolean)@deprecated. Please use the ‘isSuperscript’ property instead. Gets or sets a value indicating whether the font is super script.
isSubscript()@deprecated. Please use the ‘isSubscript’ property instead. Gets or sets a value indicating whether the font is subscript.
setIsSubscript(boolean)@deprecated. Please use the ‘isSubscript’ property instead. Gets or sets a value indicating whether the font is subscript.
getUnderline()@deprecated. Please use the ‘underline’ property instead. Gets or sets the font underline type.
setUnderline(FontUnderlineType)@deprecated. Please use the ‘underline’ property instead. Gets or sets the font underline type.
getDoubleSize()@deprecated. Please use the ‘doubleSize’ property instead. Gets and sets the double size of the font.
setDoubleSize(number)@deprecated. Please use the ‘doubleSize’ property instead. Gets and sets the double size of the font.
getSize()@deprecated. Please use the ‘size’ property instead. Gets or sets the size of the font.
setSize(number)@deprecated. Please use the ‘size’ property instead. Gets or sets the size of the font.
getThemeColor()@deprecated. Please use the ’themeColor’ property instead. Gets and sets the theme color.
setThemeColor(ThemeColor)@deprecated. Please use the ’themeColor’ property instead. Gets and sets the theme color.
getColor()@deprecated. Please use the ‘color’ property instead. Gets or sets the Color of the font.
setColor(Color)@deprecated. Please use the ‘color’ property instead. Gets or sets the Color of the font.
getArgbColor()@deprecated. Please use the ‘argbColor’ property instead. Gets and sets the color with a 32-bit ARGB value.
setArgbColor(number)@deprecated. Please use the ‘argbColor’ property instead. Gets and sets the color with a 32-bit ARGB value.
isNormalizeHeights()@deprecated. Please use the ‘isNormalizeHeights’ property instead. Indicates whether the normalization of height that is to be applied to the text run.
setIsNormalizeHeights(boolean)@deprecated. Please use the ‘isNormalizeHeights’ property instead. Indicates whether the normalization of height that is to be applied to the text run.
getSchemeType()@deprecated. Please use the ‘schemeType’ property instead. Gets and sets the scheme type of the font.
setSchemeType(FontSchemeType)@deprecated. Please use the ‘schemeType’ property instead. Gets and sets the scheme type of the font.
equals(Font)Checks if two fonts are equals.
isNull()Checks whether the implementation object is null.
getName()Gets or sets the name of the Font.
setName(string)Gets or sets the name of the Font.
toString()Returns a string represents the current Cell object.

charset

Represent the character set.

charset : number;

isItalic

Gets or sets a value indicating whether the font is italic.

isItalic : boolean;

isBold

Gets or sets a value indicating whether the font is bold.

isBold : boolean;

capsType

Gets and sets the text caps type.

capsType : TextCapsType;

strikeType

Gets the strike type of the text.

strikeType : TextStrikeType;

isStrikeout

Gets or sets a value indicating whether the font is single strikeout.

isStrikeout : boolean;

scriptOffset

Gets and sets the script offset,in unit of percentage

scriptOffset : number;

isSuperscript

Gets or sets a value indicating whether the font is super script.

isSuperscript : boolean;

isSubscript

Gets or sets a value indicating whether the font is subscript.

isSubscript : boolean;

underline

Gets or sets the font underline type.

underline : FontUnderlineType;

doubleSize

Gets and sets the double size of the font.

doubleSize : number;

size

Gets or sets the size of the font.

size : number;

themeColor

Gets and sets the theme color.

themeColor : ThemeColor;

Remarks

If the font color is not a theme color, NULL will be returned.

color

Gets or sets the Color of the font.

color : Color;

argbColor

Gets and sets the color with a 32-bit ARGB value.

argbColor : number;

isNormalizeHeights

Indicates whether the normalization of height that is to be applied to the text run.

isNormalizeHeights : boolean;

schemeType

Gets and sets the scheme type of the font.

schemeType : FontSchemeType;

getCharset()

@deprecated. Please use the ‘charset’ property instead. Represent the character set.

getCharset() : number;

setCharset(number)

@deprecated. Please use the ‘charset’ property instead. Represent the character set.

setCharset(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

isItalic()

@deprecated. Please use the ‘isItalic’ property instead. Gets or sets a value indicating whether the font is italic.

isItalic() : boolean;

setIsItalic(boolean)

@deprecated. Please use the ‘isItalic’ property instead. Gets or sets a value indicating whether the font is italic.

setIsItalic(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

isBold()

@deprecated. Please use the ‘isBold’ property instead. Gets or sets a value indicating whether the font is bold.

isBold() : boolean;

setIsBold(boolean)

@deprecated. Please use the ‘isBold’ property instead. Gets or sets a value indicating whether the font is bold.

setIsBold(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getCapsType()

@deprecated. Please use the ‘capsType’ property instead. Gets and sets the text caps type.

getCapsType() : TextCapsType;

Returns

TextCapsType

setCapsType(TextCapsType)

@deprecated. Please use the ‘capsType’ property instead. Gets and sets the text caps type.

setCapsType(value: TextCapsType) : void;

Parameters:

ParameterTypeDescription
valueTextCapsTypeThe value to set.

getStrikeType()

@deprecated. Please use the ‘strikeType’ property instead. Gets the strike type of the text.

getStrikeType() : TextStrikeType;

Returns

TextStrikeType

setStrikeType(TextStrikeType)

@deprecated. Please use the ‘strikeType’ property instead. Gets the strike type of the text.

setStrikeType(value: TextStrikeType) : void;

Parameters:

ParameterTypeDescription
valueTextStrikeTypeThe value to set.

isStrikeout()

@deprecated. Please use the ‘isStrikeout’ property instead. Gets or sets a value indicating whether the font is single strikeout.

isStrikeout() : boolean;

setIsStrikeout(boolean)

@deprecated. Please use the ‘isStrikeout’ property instead. Gets or sets a value indicating whether the font is single strikeout.

setIsStrikeout(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getScriptOffset()

@deprecated. Please use the ‘scriptOffset’ property instead. Gets and sets the script offset,in unit of percentage

getScriptOffset() : number;

setScriptOffset(number)

@deprecated. Please use the ‘scriptOffset’ property instead. Gets and sets the script offset,in unit of percentage

setScriptOffset(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

isSuperscript()

@deprecated. Please use the ‘isSuperscript’ property instead. Gets or sets a value indicating whether the font is super script.

isSuperscript() : boolean;

setIsSuperscript(boolean)

@deprecated. Please use the ‘isSuperscript’ property instead. Gets or sets a value indicating whether the font is super script.

setIsSuperscript(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

isSubscript()

@deprecated. Please use the ‘isSubscript’ property instead. Gets or sets a value indicating whether the font is subscript.

isSubscript() : boolean;

setIsSubscript(boolean)

@deprecated. Please use the ‘isSubscript’ property instead. Gets or sets a value indicating whether the font is subscript.

setIsSubscript(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getUnderline()

@deprecated. Please use the ‘underline’ property instead. Gets or sets the font underline type.

getUnderline() : FontUnderlineType;

Returns

FontUnderlineType

setUnderline(FontUnderlineType)

@deprecated. Please use the ‘underline’ property instead. Gets or sets the font underline type.

setUnderline(value: FontUnderlineType) : void;

Parameters:

ParameterTypeDescription
valueFontUnderlineTypeThe value to set.

getDoubleSize()

@deprecated. Please use the ‘doubleSize’ property instead. Gets and sets the double size of the font.

getDoubleSize() : number;

setDoubleSize(number)

@deprecated. Please use the ‘doubleSize’ property instead. Gets and sets the double size of the font.

setDoubleSize(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getSize()

@deprecated. Please use the ‘size’ property instead. Gets or sets the size of the font.

getSize() : number;

setSize(number)

@deprecated. Please use the ‘size’ property instead. Gets or sets the size of the font.

setSize(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getThemeColor()

@deprecated. Please use the ’themeColor’ property instead. Gets and sets the theme color.

getThemeColor() : ThemeColor;

Returns

ThemeColor

Remarks

If the font color is not a theme color, NULL will be returned.

setThemeColor(ThemeColor)

@deprecated. Please use the ’themeColor’ property instead. Gets and sets the theme color.

setThemeColor(value: ThemeColor) : void;

Parameters:

ParameterTypeDescription
valueThemeColorThe value to set.

Remarks

If the font color is not a theme color, NULL will be returned.

getColor()

@deprecated. Please use the ‘color’ property instead. Gets or sets the Color of the font.

getColor() : Color;

Returns

Color

setColor(Color)

@deprecated. Please use the ‘color’ property instead. Gets or sets the Color of the font.

setColor(value: Color) : void;

Parameters:

ParameterTypeDescription
valueColorThe value to set.

getArgbColor()

@deprecated. Please use the ‘argbColor’ property instead. Gets and sets the color with a 32-bit ARGB value.

getArgbColor() : number;

setArgbColor(number)

@deprecated. Please use the ‘argbColor’ property instead. Gets and sets the color with a 32-bit ARGB value.

setArgbColor(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

isNormalizeHeights()

@deprecated. Please use the ‘isNormalizeHeights’ property instead. Indicates whether the normalization of height that is to be applied to the text run.

isNormalizeHeights() : boolean;

setIsNormalizeHeights(boolean)

@deprecated. Please use the ‘isNormalizeHeights’ property instead. Indicates whether the normalization of height that is to be applied to the text run.

setIsNormalizeHeights(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getSchemeType()

@deprecated. Please use the ‘schemeType’ property instead. Gets and sets the scheme type of the font.

getSchemeType() : FontSchemeType;

Returns

FontSchemeType

setSchemeType(FontSchemeType)

@deprecated. Please use the ‘schemeType’ property instead. Gets and sets the scheme type of the font.

setSchemeType(value: FontSchemeType) : void;

Parameters:

ParameterTypeDescription
valueFontSchemeTypeThe value to set.

equals(Font)

Checks if two fonts are equals.

equals(font: Font) : boolean;

Parameters:

ParameterTypeDescription
fontFontCompared font object.

Returns

True if equal to the compared font object.

isNull()

Checks whether the implementation object is null.

isNull() : boolean;

getName()

Gets or sets the name of the Font.

getName() : string;

setName(string)

Gets or sets the name of the Font.

setName(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

Example

const { Workbook } = require("aspose.cells.node");

var workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var worksheet = workbook.worksheets.get(0);
//Accessing the "A1" cell from the worksheet
var cell = worksheet.cells.get("A1");
//Adding some value to the "A1" cell
cell.putValue("Hello Aspose!");
var style = cell.getStyle();
var font = style.font;
font.setName("Times New Roman");
cell.setStyle(style);

toString()

Returns a string represents the current Cell object.

toString() : string;