ExcelScript.RangeBorder interface

Represents the border of an object.

Methods

getColor()

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

getSideIndex()

Constant value that indicates the specific side of the border. See ExcelScript.BorderIndex for details.

getStyle()

One of the constants of line style specifying the line style for the border. See ExcelScript.BorderLineStyle for details.

getTintAndShade()

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

getWeight()

Specifies the weight of the border around a range. See ExcelScript.BorderWeight for details.

setColor(color)

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

setStyle(style)

One of the constants of line style specifying the line style for the border. See ExcelScript.BorderLineStyle for details.

setTintAndShade(tintAndShade)

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

setWeight(weight)

Specifies the weight of the border around a range. See ExcelScript.BorderWeight for details.

Method Details

getColor()

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

getColor(): string;

Returns

string

getSideIndex()

Constant value that indicates the specific side of the border. See ExcelScript.BorderIndex for details.

getSideIndex(): BorderIndex;

Returns

getStyle()

One of the constants of line style specifying the line style for the border. See ExcelScript.BorderLineStyle for details.

getStyle(): BorderLineStyle;

Returns

getTintAndShade()

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

getTintAndShade(): number;

Returns

number

getWeight()

Specifies the weight of the border around a range. See ExcelScript.BorderWeight for details.

getWeight(): BorderWeight;

Returns

setColor(color)

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

setColor(color: string): void;

Parameters

color

string

Returns

void

setStyle(style)

One of the constants of line style specifying the line style for the border. See ExcelScript.BorderLineStyle for details.

setStyle(style: BorderLineStyle): void;

Parameters

Returns

void

Examples

/**
 * This script adds a border around the outside of a range.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get a range from the current worksheet.
  let range = workbook.getActiveWorksheet().getRange("B2:E15");

  // Add a border around the whole bounding range.
  let format = range.getFormat();
  format.getRangeBorder(ExcelScript.BorderIndex.edgeTop).setStyle(ExcelScript.BorderLineStyle.continuous); // Top border
  format.getRangeBorder(ExcelScript.BorderIndex.edgeBottom).setStyle(ExcelScript.BorderLineStyle.continuous); // Bottom border
  format.getRangeBorder(ExcelScript.BorderIndex.edgeLeft).setStyle(ExcelScript.BorderLineStyle.continuous); // Left border
  format.getRangeBorder(ExcelScript.BorderIndex.edgeRight).setStyle(ExcelScript.BorderLineStyle.continuous); // Right border
}

setTintAndShade(tintAndShade)

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

setTintAndShade(tintAndShade: number): void;

Parameters

tintAndShade

number

Returns

void

setWeight(weight)

Specifies the weight of the border around a range. See ExcelScript.BorderWeight for details.

setWeight(weight: BorderWeight): void;

Parameters

Returns

void

Examples

/**
 * This script creates a border around a range.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the RangeFormat object for the range "B2:G10".
  const currentSheet = workbook.getActiveWorksheet();
  const rangeForBorder = currentSheet.getRange("B2:G10");
  const format = rangeForBorder.getFormat();
  
  // Get a RangeBorder object for each edge of the range and set the border properties.
  let edgeTop = format.getRangeBorder(ExcelScript.BorderIndex.edgeTop);
  edgeTop.setStyle(ExcelScript.BorderLineStyle.dashDot);
  edgeTop.setWeight(ExcelScript.BorderWeight.thick);

  let edgeBottom = format.getRangeBorder(ExcelScript.BorderIndex.edgeBottom);
  edgeBottom.setStyle(ExcelScript.BorderLineStyle.dashDot);
  edgeBottom.setWeight(ExcelScript.BorderWeight.thick);

  let edgeLeft = format.getRangeBorder(ExcelScript.BorderIndex.edgeLeft);
  edgeLeft.setStyle(ExcelScript.BorderLineStyle.dashDot);
  edgeLeft.setWeight(ExcelScript.BorderWeight.thick);

  let edgeRight = format.getRangeBorder(ExcelScript.BorderIndex.edgeRight);
  edgeRight.setStyle(ExcelScript.BorderLineStyle.dashDot);
  edgeRight.setWeight(ExcelScript.BorderWeight.thick);
}