Excel.ChartFill class

Represents the fill formatting for a chart element.

Extends

Remarks

[ API set: ExcelApi 1.1 ]

Properties

context

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

Methods

clear()

Clears the fill color of a chart element.

getSolidColor()

Gets the uniform color fill formatting of a chart element.

setSolidColor(color)

Sets the fill formatting of a chart element to a uniform color.

Property Details

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

Method Details

clear()

Clears the fill color of a chart element.

clear(): void;

Returns

void

Remarks

[ API set: ExcelApi 1.1 ]

Examples

// 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()

Gets the uniform color fill formatting of a chart element.

getSolidColor(): OfficeExtension.ClientResult<string>;

Returns

Remarks

[ API set: ExcelApi 1.16 ]

setSolidColor(color)

Sets the fill formatting of a chart element to a uniform color.

setSolidColor(color: string): void;

Parameters

color

string

HTML color code representing the color of the background, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

Returns

void

Remarks

[ API set: ExcelApi 1.1 ]

Examples

// 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();        
});