ExcelScript.RangeFill interface

Represents the background of a range object.

Remarks

Examples

/**
 * This script sets the fill color of the used range to green.
 */
function main(workbook: ExcelScript.Workbook)
{
  // Get the used range of the current worksheet.
  let currentSheet = workbook.getActiveWorksheet();
  let usedRange = currentSheet.getUsedRange();

  // Get the RangeFill object.
  let fill = usedRange.getFormat().getFill();

  // Set the fill color to green.
  fill.setColor("green");
}

Methods

clear()

Resets the range background.

getColor()

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")

getPattern()

The pattern of a range. See ExcelScript.FillPattern for details. LinearGradient and RectangularGradient are not supported. A null value indicates that the entire range doesn't have a uniform pattern setting.

getPatternColor()

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

getPatternTintAndShade()

Specifies a double that lightens or darkens a pattern color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform patternTintAndShade settings.

getTintAndShade()

Specifies a double that lightens or darkens a color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform tintAndShade settings.

setColor(color)

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")

setPattern(pattern)

The pattern of a range. See ExcelScript.FillPattern for details. LinearGradient and RectangularGradient are not supported. A null value indicates that the entire range doesn't have a uniform pattern setting.

setPatternColor(patternColor)

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

setPatternTintAndShade(patternTintAndShade)

Specifies a double that lightens or darkens a pattern color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform patternTintAndShade settings.

setTintAndShade(tintAndShade)

Specifies a double that lightens or darkens a color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform tintAndShade settings.

Method Details

clear()

Resets the range background.

clear(): void;

Returns

void

Examples

/**
 * This script removes all fill color and styles from the used range.
 */
function main(workbook: ExcelScript.Workbook)
{
  // Get the used range of the current worksheet.
  let currentSheet = workbook.getActiveWorksheet();
  let usedRange = currentSheet.getUsedRange();

  // Clear the fill from the entire range.
  usedRange.getFormat().getFill().clear();
}

getColor()

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")

getColor(): string;

Returns

string

getPattern()

The pattern of a range. See ExcelScript.FillPattern for details. LinearGradient and RectangularGradient are not supported. A null value indicates that the entire range doesn't have a uniform pattern setting.

getPattern(): FillPattern;

Returns

getPatternColor()

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

getPatternColor(): string;

Returns

string

getPatternTintAndShade()

Specifies a double that lightens or darkens a pattern color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform patternTintAndShade settings.

getPatternTintAndShade(): number;

Returns

number

getTintAndShade()

Specifies a double that lightens or darkens a color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform tintAndShade settings.

getTintAndShade(): number;

Returns

number

setColor(color)

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")

setColor(color: string): void;

Parameters

color

string

Returns

void

Examples

/**
 * This script sets the fill color of cell A2 to blue.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the range representing cell A2 from the current worksheet.
  let cell = workbook.getActiveWorksheet().getRange("A2");

  // Set the fill color to blue.
  cell.getFormat().getFill().setColor("blue");
}

setPattern(pattern)

The pattern of a range. See ExcelScript.FillPattern for details. LinearGradient and RectangularGradient are not supported. A null value indicates that the entire range doesn't have a uniform pattern setting.

setPattern(pattern: FillPattern): void;

Parameters

Returns

void

Examples

/**
 * This script sets a black-checkered fill on the selected range.
 */
function main(workbook: ExcelScript.Workbook) {
  const selected = workbook.getSelectedRange();
  selected.getFormat().getFill().setPattern(ExcelScript.FillPattern.checker);
  selected.getFormat().getFill().setPatternColor("black");
}

setPatternColor(patternColor)

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

setPatternColor(patternColor: string): void;

Parameters

patternColor

string

Returns

void

setPatternTintAndShade(patternTintAndShade)

Specifies a double that lightens or darkens a pattern color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform patternTintAndShade settings.

setPatternTintAndShade(patternTintAndShade: number): void;

Parameters

patternTintAndShade

number

Returns

void

setTintAndShade(tintAndShade)

Specifies a double that lightens or darkens a color for the range fill. The value is between -1 (darkest) and 1 (brightest), with 0 for the original color. A null value indicates that the range doesn't have uniform tintAndShade settings.

setTintAndShade(tintAndShade: number): void;

Parameters

tintAndShade

number

Returns

void