Excel.ChartFill class

表示图表元素的格式填充。

Extends

注解

[ API 集:ExcelApi 1.1 ]

属性

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

方法

clear()

清除图表元素的填充颜色。

getSolidColor()

获取图表元素的统一颜色填充格式。

setSolidColor(color)

将图表元素的填充格式设置为统一颜色。

属性详细信息

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

方法详细信息

clear()

清除图表元素的填充颜色。

clear(): void;

返回

void

注解

[ API 集:ExcelApi 1.1 ]

示例

// Clear the line format of the major gridlines on the value axis of the chart named "Chart1".
await Excel.run(async (context) => { 
    const gridlines = context.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1").axes.valueAxis.majorGridlines;
    gridlines.format.line.clear();
    await context.sync();
    
    console.log("Chart Major Gridlines Format Cleared");
});

getSolidColor()

获取图表元素的统一颜色填充格式。

getSolidColor(): OfficeExtension.ClientResult<string>;

返回

注解

[ API 集:ExcelApi 1.16 ]

setSolidColor(color)

将图表元素的填充格式设置为统一颜色。

setSolidColor(color: string): void;

参数

color

string

表示背景颜色的 HTML 颜色代码,格式#RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“orange”) 。

返回

void

注解

[ API 集:ExcelApi 1.1 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-point.yaml

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");

    let pointsCollection = sheet.charts.getItemAt(0).series.getItemAt(0).points;
    let point = pointsCollection.getItemAt(2);

    // Set color for chart point.
    point.format.fill.setSolidColor('red');

    await context.sync();        
});