Excel.ChartTitle class

表示图表的图表标题对象。Represents a chart title object of a chart.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

Extends

属性

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

format

表示图表标题的格式,包括填充和字体格式。Represents the formatting of a chart title, which includes fill and font formatting. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

height

返回图表标题的高度,以磅为单位。Returns the height, in points, of the chart title. 如果图表标题不可见, 则为 Null。Null if chart title is not visible. 只读。Read-only.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

horizontalAlignment

表示图表标题水平对齐。Represents the horizontal alignment for chart title.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

left

表示图表标题左边缘到图表区域左边缘的距离,以磅为单位。Represents the distance, in points, from the left edge of chart title to the left edge of chart area. 如果图表标题不可见, 则为 Null。Null if chart title is not visible.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

overlay

表示图表标题是否将叠加在图表上的布尔值。Boolean value representing if the chart title will overlay the chart or not.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

position

表示图表标题的位置。Represents the position of chart title. 有关详细信息, 请参阅 ChartTitlePosition。See Excel.ChartTitlePosition for details.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

showShadow

表示一个布尔值,用于确定图表标题是否具有阴影。Represents a boolean value that determines if the chart title has a shadow.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

text

表示图表的标题文本。Represents the title text of a chart.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

textOrientation

表示图表标题的文本方向。Represents the text orientation of chart title. 此值应是 -90 到 90 或 180(垂直文本)之间的整数。The value should be an integer either from -90 to 90, or 180 for vertically-oriented text.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

top

表示图表标题上边缘到图表区域顶部的距离,以磅为单位。Represents the distance, in points, from the top edge of chart title to the top of chart area. 如果图表标题不可见, 则为 Null。Null if chart title is not visible.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

verticalAlignment

表示图表标题垂直对齐。Represents the vertical alignment of chart title. 有关详细信息, 请参阅 ChartTextVerticalAlignment。See Excel.ChartTextVerticalAlignment for details.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

visible

表示图表标题对象是否可见的布尔值。A boolean value the represents the visibility of a chart title object.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

width

返回图表标题的宽度,以磅为单位。Returns the width, in points, of the chart title. 如果图表标题不可见, 则为 Null。Null if chart title is not visible. 只读。Read-only.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

方法

getSubstring(start, length)

获取图表标题的子字符串。Get the substring of a chart title. 换行符 "Line break '\n ' 也计算一个字符。n' also counts one character.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

setFormula(formula)

设置一个字符串值,用于表示采用 A1 表示法的图表标题的公式。Sets a string value that represents the formula of chart title using A1-style notation.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始 ChartTitle 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.ChartTitleData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ChartTitle object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ChartTitleData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

属性详细信息

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

context: RequestContext;

属性值

RequestContext

format

表示图表标题的格式,包括填充和字体格式。Represents the formatting of a chart title, which includes fill and font formatting. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

readonly format: Excel.ChartTitleFormat;

属性值

height

返回图表标题的高度,以磅为单位。Returns the height, in points, of the chart title. 如果图表标题不可见, 则为 Null。Null if chart title is not visible. 只读。Read-only.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

readonly height: number;

属性值

number

horizontalAlignment

表示图表标题水平对齐。Represents the horizontal alignment for chart title.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

horizontalAlignment: Excel.ChartTextHorizontalAlignment | "Center" | "Left" | "Right" | "Justify" | "Distributed";

属性值

Excel.ChartTextHorizontalAlignment | "Center" | "Left" | "Right" | "Justify" | "Distributed"

left

表示图表标题左边缘到图表区域左边缘的距离,以磅为单位。Represents the distance, in points, from the left edge of chart title to the left edge of chart area. 如果图表标题不可见, 则为 Null。Null if chart title is not visible.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

left: number;

属性值

number

overlay

表示图表标题是否将叠加在图表上的布尔值。Boolean value representing if the chart title will overlay the chart or not.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

overlay: boolean;

属性值

boolean

position

表示图表标题的位置。Represents the position of chart title. 有关详细信息, 请参阅 ChartTitlePosition。See Excel.ChartTitlePosition for details.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

position: Excel.ChartTitlePosition | "Automatic" | "Top" | "Bottom" | "Left" | "Right";

属性值

Excel.ChartTitlePosition | "Automatic" | "Top" | "Bottom" | "Left" | "Right"

showShadow

表示一个布尔值,用于确定图表标题是否具有阴影。Represents a boolean value that determines if the chart title has a shadow.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

showShadow: boolean;

属性值

boolean

text

表示图表的标题文本。Represents the title text of a chart.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

text: string;

属性值

string

textOrientation

表示图表标题的文本方向。Represents the text orientation of chart title. 此值应是 -90 到 90 或 180(垂直文本)之间的整数。The value should be an integer either from -90 to 90, or 180 for vertically-oriented text.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

textOrientation: number;

属性值

number

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const title = sheet.charts.getItemAt(0).title;
    title.textOrientation = -45;

    await context.sync();
});

top

表示图表标题上边缘到图表区域顶部的距离,以磅为单位。Represents the distance, in points, from the top edge of chart title to the top of chart area. 如果图表标题不可见, 则为 Null。Null if chart title is not visible.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

top: number;

属性值

number

verticalAlignment

表示图表标题垂直对齐。Represents the vertical alignment of chart title. 有关详细信息, 请参阅 ChartTextVerticalAlignment。See Excel.ChartTextVerticalAlignment for details.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

verticalAlignment: Excel.ChartTextVerticalAlignment | "Center" | "Bottom" | "Top" | "Justify" | "Distributed";

属性值

Excel.ChartTextVerticalAlignment | "Center" | "Bottom" | "Top" | "Justify" | "Distributed"

visible

表示图表标题对象是否可见的布尔值。A boolean value the represents the visibility of a chart title object.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

visible: boolean;

属性值

boolean

width

返回图表标题的宽度,以磅为单位。Returns the width, in points, of the chart title. 如果图表标题不可见, 则为 Null。Null if chart title is not visible. 只读。Read-only.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

readonly width: number;

属性值

number

方法详细信息

getSubstring(start, length)

获取图表标题的子字符串。Get the substring of a chart title. 换行符 "Line break '\n ' 也计算一个字符。n' also counts one character.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

getSubstring(start: number, length: number): Excel.ChartFormatString;

参数

start
number

要检索的子字符串的起始位置。Start position of substring to be retrieved. 位置从0开始。Position start with 0.

length
number

要检索的子字符串的长度。Length of substring to be retrieved.

返回

示例Examples

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let chart = sheet.charts.getItemAt(0);

    // Get first seven characters of the title and color them green.
    chart.title.getSubstring(0, 7).font.color = "Yellow";
    await context.sync();
});

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(option?: Excel.Interfaces.ChartTitleLoadOptions): Excel.ChartTitle;

参数

返回

注解

除了此签名之外, 此方法还具有以下签名:In addition to this signature, this method has the following signatures:

load(option?: string | string[]): Excel.ChartTitle-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.ChartTitle - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Excel.ChartTitle-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.ChartTitle - 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.ChartTitle-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ChartTitle - Only available on collection types. 它类似于前面的签名。It is similar to the preceding signature. top 指定结果中可包含的集合项的最大数量。Option.top specifies the maximum number of collection items that can be included in the result. 选项。 skip 指定要跳过且不包含在结果中的项目数。Option.skip specifies the number of items that are to be skipped and not included in the result. 如果指定了 top 选项, 则在跳过指定数目的项目后将启动结果集。If option.top is specified, the result set will start after skipping the specified number of items.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.ChartTitle;

参数

propertyNames
string | string[]

一个以逗号分隔的字符串或字符串数组, 用于指定要加载的属性。A comma-delimited string or an array of strings that specify the properties to load.

返回

示例Examples

// Get the text of Chart Title from Chart1.
Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");    
    
    var title = chart.title;
    title.load('text');
    return ctx.sync().then(function() {
            console.log(title.text);
    }).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
    });
});
// Set the text of Chart Title to "My Chart" and Make it show on top of the chart without overlaying.
Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");    
    
    chart.title.text= "My Chart"; 
    chart.title.visible=true;
    chart.title.overlay=true;
    
    return ctx.sync().then(function() {
        console.log("Char Title Changed");
    }).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
    });
});

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: { select?: string; expand?: string; }): Excel.ChartTitle;

参数

propertyNamesAndPaths
{ select?: string; expand?: string; }

其中, propertyNamesAndPaths 是用逗号分隔的字符串, 用于指定要加载的属性和 propertyNamesAndPaths。扩展是一个用逗号分隔的字符串, 用于指定要加载的导航属性。Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

返回

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.ChartTitleUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.ChartTitleUpdateData

一个 JavaScript 对象, 其属性的结构 isomorphically 为在其上调用方法的对象的属性。A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

提供一个选项, 以在 properties 对象尝试设置任何只读属性时禁止显示错误。Provides an option to suppress errors if the properties object tries to set any read-only properties.

返回

void

注解

此方法具有以下附加签名:This method has the following additional signature:

set(properties: Excel.ChartTitle): void

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.ChartTitle): void;

参数

properties
Excel.ChartTitle

返回

void

setFormula(formula)

设置一个字符串值,用于表示采用 A1 表示法的图表标题的公式。Sets a string value that represents the formula of chart title using A1-style notation.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

setFormula(formula: string): void;

参数

formula
string

一个字符串, 表示要设置的公式。A string that represents the formula to set.

返回

void

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始 ChartTitle 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.ChartTitleData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ChartTitle object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ChartTitleData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.ChartTitleData;

返回