Excel.ChartFont class

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

[ API set: ExcelApi 1.1 ]

Extends

Remarks

Examples

// Set chart title to be Calbri, size 10, bold and in red. 
Excel.run(function (ctx) { 
    var title = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1").title;
    title.format.font.name = "Calibri";
    title.format.font.size = 12;
    title.format.font.color = "#FF0000";
    title.format.font.italic =  false;
    title.format.font.bold = true;
    title.format.font.underline = "None";
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

Properties

bold

Represents the bold status of font.

[ API set: ExcelApi 1.1 ]

color

HTML color code representation of the text color. E.g. #FF0000 represents Red.

[ API set: ExcelApi 1.1 ]

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

italic

Represents the italic status of the font.

[ API set: ExcelApi 1.1 ]

name

Font name (e.g. "Calibri")

[ API set: ExcelApi 1.1 ]

size

Size of the font (e.g. 11)

[ API set: ExcelApi 1.1 ]

underline

Type of underline applied to the font. See Excel.ChartUnderlineStyle for details.

[ API set: ExcelApi 1.1 ]

Methods

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ChartFont object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ChartFontData) that contains shallow copies of any loaded child properties from the original object.

Property Details

bold

Represents the bold status of font.

[ API set: ExcelApi 1.1 ]

bold: boolean;

Property Value

boolean

color

HTML color code representation of the text color. E.g. #FF0000 represents Red.

[ API set: ExcelApi 1.1 ]

color: string;

Property Value

string

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

RequestContext

italic

Represents the italic status of the font.

[ API set: ExcelApi 1.1 ]

italic: boolean;

Property Value

boolean

name

Font name (e.g. "Calibri")

[ API set: ExcelApi 1.1 ]

name: string;

Property Value

string

size

Size of the font (e.g. 11)

[ API set: ExcelApi 1.1 ]

size: number;

Property Value

number

underline

Type of underline applied to the font. See Excel.ChartUnderlineStyle for details.

[ API set: ExcelApi 1.1 ]

underline: Excel.ChartUnderlineStyle | "None" | "Single";

Property Value

Excel.ChartUnderlineStyle | "None" | "Single"

Method Details

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Excel.ChartFont;

Parameters

option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Excel.ChartFont - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ChartFont - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ChartFont object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ChartFontData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.ChartFontData;

Returns