ExcelScript.DataBarConditionalFormat interface

Represents an Excel conditional data bar type.

Remarks

Examples

/**
 * This script creates data bar conditional formatting on the selected range.
 * The scale of the data bar goes from 0 to 1000.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the selected range.
  const selected = workbook.getSelectedRange();
  
  // Create new conditional formatting on the range.
  const format = selected.addConditionalFormat(ExcelScript.ConditionalFormatType.dataBar);
  const dataBarFormat: ExcelScript.DataBarConditionalFormat = format.getDataBar();

  // Set the lower bound of the data bar formatting to be 0.
  const lowerBound: ExcelScript.ConditionalDataBarRule = {
    type: ExcelScript.ConditionalFormatRuleType.number,
    formula: "0"
  };
  dataBarFormat.setLowerBoundRule(lowerBound);

  // Set the upper bound of the data bar formatting to be 1000.
  const upperBound: ExcelScript.ConditionalDataBarRule = {
    type: ExcelScript.ConditionalFormatRuleType.number,
    formula: "1000"
  };
  dataBarFormat.setUpperBoundRule(upperBound);
}

Methods

getAxisColor()

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

getAxisFormat()

Representation of how the axis is determined for an Excel data bar.

getBarDirection()

Specifies the direction that the data bar graphic should be based on.

getLowerBoundRule()

The rule for what constitutes the lower bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.lowerBoundRule = {...} instead of x.lowerBoundRule.formula = ...).

getNegativeFormat()

Representation of all values to the left of the axis in an Excel data bar.

getPositiveFormat()

Representation of all values to the right of the axis in an Excel data bar.

getShowDataBarOnly()

If true, hides the values from the cells where the data bar is applied.

getUpperBoundRule()

The rule for what constitutes the upper bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.upperBoundRule = {...} instead of x.upperBoundRule.formula = ...).

setAxisColor(axisColor)

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

setAxisFormat(axisFormat)

Representation of how the axis is determined for an Excel data bar.

setBarDirection(barDirection)

Specifies the direction that the data bar graphic should be based on.

setLowerBoundRule(lowerBoundRule)

The rule for what constitutes the lower bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.lowerBoundRule = {...} instead of x.lowerBoundRule.formula = ...).

setShowDataBarOnly(showDataBarOnly)

If true, hides the values from the cells where the data bar is applied.

setUpperBoundRule(upperBoundRule)

The rule for what constitutes the upper bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.upperBoundRule = {...} instead of x.upperBoundRule.formula = ...).

Method Details

getAxisColor()

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

getAxisColor(): string;

Returns

string

getAxisFormat()

Representation of how the axis is determined for an Excel data bar.

getAxisFormat(): ConditionalDataBarAxisFormat;

Returns

getBarDirection()

Specifies the direction that the data bar graphic should be based on.

getBarDirection(): ConditionalDataBarDirection;

Returns

getLowerBoundRule()

The rule for what constitutes the lower bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.lowerBoundRule = {...} instead of x.lowerBoundRule.formula = ...).

getLowerBoundRule(): ConditionalDataBarRule;

Returns

getNegativeFormat()

Representation of all values to the left of the axis in an Excel data bar.

getNegativeFormat(): ConditionalDataBarNegativeFormat;

Returns

getPositiveFormat()

Representation of all values to the right of the axis in an Excel data bar.

getPositiveFormat(): ConditionalDataBarPositiveFormat;

Returns

getShowDataBarOnly()

If true, hides the values from the cells where the data bar is applied.

getShowDataBarOnly(): boolean;

Returns

boolean

getUpperBoundRule()

The rule for what constitutes the upper bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.upperBoundRule = {...} instead of x.upperBoundRule.formula = ...).

getUpperBoundRule(): ConditionalDataBarRule;

Returns

setAxisColor(axisColor)

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

setAxisColor(axisColor: string): void;

Parameters

axisColor

string

Returns

void

setAxisFormat(axisFormat)

Representation of how the axis is determined for an Excel data bar.

setAxisFormat(axisFormat: ConditionalDataBarAxisFormat): void;

Parameters

Returns

void

setBarDirection(barDirection)

Specifies the direction that the data bar graphic should be based on.

setBarDirection(barDirection: ConditionalDataBarDirection): void;

Parameters

Returns

void

setLowerBoundRule(lowerBoundRule)

The rule for what constitutes the lower bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.lowerBoundRule = {...} instead of x.lowerBoundRule.formula = ...).

setLowerBoundRule(lowerBoundRule: ConditionalDataBarRule): void;

Parameters

Returns

void

setShowDataBarOnly(showDataBarOnly)

If true, hides the values from the cells where the data bar is applied.

setShowDataBarOnly(showDataBarOnly: boolean): void;

Parameters

showDataBarOnly

boolean

Returns

void

setUpperBoundRule(upperBoundRule)

The rule for what constitutes the upper bound (and how to calculate it, if applicable) for a data bar. The ConditionalDataBarRule object must be set as a JSON object (use x.upperBoundRule = {...} instead of x.upperBoundRule.formula = ...).

setUpperBoundRule(upperBoundRule: ConditionalDataBarRule): void;

Parameters

Returns

void