Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ExcelScript.ConditionalDataBarPositiveFormat interface

Package:
ExcelScript

Represents a conditional format for the positive side of the data bar.

Remarks

Used by

Examples

/**
 * This script applies data bar conditional formatting to a range.
 * It sets the data bar colors to be green when positive and red when negative.
 */
function main(workbook: ExcelScript.Workbook) {
 // Get the "Sales" data column range in a table named "SalesTable".
 const table = workbook.getTable("SalesTable");
 const salesRange = table.getColumnByName("Sales").getRangeBetweenHeaderAndTotal();

 // Add data bar conditional formatting to the range.
 const cf = salesRange.addConditionalFormat(ExcelScript.ConditionalFormatType.dataBar);

 // Have the bar show green when positive and red when negative. 
 const dataBarConditionalFormat = cf.getDataBar();
 const positiveFormat: ExcelScript.ConditionalDataBarPositiveFormat = dataBarConditionalFormat.getPositiveFormat();
 positiveFormat .setFillColor("green");
 const negativeFormat: ExcelScript.ConditionalDataBarNegativeFormat = dataBarConditionalFormat.getNegativeFormat();
 negativeFormat.setFillColor("red");
}

Methods

getBorderColor()

HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.

getFillColor()

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

getGradientFill()

Specifies if the data bar has a gradient.

setBorderColor(borderColor)

HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.

setFillColor(fillColor)

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

setGradientFill(gradientFill)

Specifies if the data bar has a gradient.

Method Details

getBorderColor()

HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.

getBorderColor(): string;

Returns

string

getFillColor()

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

getFillColor(): string;

Returns

string

getGradientFill()

Specifies if the data bar has a gradient.

getGradientFill(): boolean;

Returns

boolean

setBorderColor(borderColor)

HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.

setBorderColor(borderColor: string): void;

Parameters

borderColor

string

Returns

void

setFillColor(fillColor)

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

setFillColor(fillColor: string): void;

Parameters

fillColor

string

Returns

void

setGradientFill(gradientFill)

Specifies if the data bar has a gradient.

setGradientFill(gradientFill: boolean): void;

Parameters

gradientFill

boolean

Returns

void


Feedback

Was this page helpful?