Skip to main content

Cell Background Color and Border

APIDescriptionExample
Range.InteriorProperty that returns the background management object for the specified rangelet range = instance.Application.ActiveSheet.Range("A1");

let interior = range.Interior;
Interior.ColorProperty that returns or changes the background color of the specified range
cf) RGB numeric value corresponding to color must be used
function RGBToInteger(rgbText) {
const [r,g,b] = rgbText.match(/\d+/g).map(Number);
return r + g * 256 + b * 65536;
}

let interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.Color);
interior.Color = RGBToInteger("RGB(255,199,206)");
Interior.ColorIndexProperty that returns or changes the background color of the specified range using index methodlet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.ColorIndex);
interior.ColorIndex = 1;
Interior.PatternProperty that returns or changes the background pattern of the specified rangelet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.Pattern);
interior.Pattern = instance.Enums.XlPattern.xlPatternCrissCross;
Interior.PatternColorProperty that returns or changes the background pattern color of the specified range
cf) RGB numeric value corresponding to color must be used
function RGBToInteger(rgbText) {
const [r,g,b] = rgbText.match(/\d+/g).map(Number);
return r + g * 256 + b * 65536;
}

let interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.PatternColor);
interior.PatternColor = RGBToInteger("RGB(255,199,206)");
Interior.PatternColorIndexProperty that returns or changes the background pattern color of the specified range using index methodlet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.PatternColorIndex);
interior.PatternColorIndex = 1;
Interior.PatternThemeColorProperty that returns or changes the background pattern theme color of the specified range using index methodlet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.PatternThemeColor);
interior.PatternThemeColor = 1;
Interior.PatternTintAndShadeProperty that returns or changes the brightness of the background pattern of the specified rangelet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.PatternTintAndShade);
interior.PatternTintAndShade = 0.3;
Interior.ThemeColorProperty that returns or changes the background theme color of the specified range using index methodlet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.ThemeColor);
interior.ThemeColor = 1;
Interior.TintAndShadeProperty that returns or changes the brightness of the background of the specified rangelet interior = instance.Application.ActiveSheet.Range("A1").Interior;

console.log(interior.TintAndShade);
interior.TintAndShade = 0.3;
Range.BordersProperty that returns the border management object for the specified rangelet range = instance.Application.ActiveSheet.Range("A1");

let borders = range.Borders;
Borders.ColorProperty that returns or changes the outer border color of the specified range
cf) RGB numeric value corresponding to color must be used
function RGBToInteger(rgbText) {
const [r,g,b] = rgbText.match(/\d+/g).map(Number);
return r + g * 256 + b * 65536;
}

let borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.Color); borders.Color = RGBToInteger("RGB(255,199,206)");
Borders.ColorIndexProperty that returns or changes the outer border color of the specified range using index methodlet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.ColorIndex);
borders.ColorIndex = 1;
Borders.CountProperty that returns the number of borders for the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.Count);
Borders.LineStyleProperty that returns or changes the outer border type of the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.LineStyle);
borders.LineStyle = instance.Enums.XlLineStyle.xlContinuous;
Borders.ThemeColorProperty that returns or changes the outer border theme color of the specified range using index methodlet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.ThemeColor);
borders.ThemeColor = 1;
Borders.TintAndShadeProperty that returns or changes the brightness of the outer border of the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.TintAndShade);
borders.TintAndShade = 0.3;
Borders.ValueProperty that returns or changes the outer border type of the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.Value);
borders.Value = instance.Enums.XlLineStyle.xlContinuous;
Borders.WeightProperty that returns or changes the thickness of the outer border of the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

console.log(borders.Weight);
borders.Weight = instance.Enums.XlBorderWeight.xlThick;
Borders.ItemFunction that returns the border object corresponding to a specific index of the specified rangelet borders = instance.Application.ActiveSheet.Range("A1").Borders;

let border = borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);
Border.ColorProperty that returns or changes the border color of the specified range
cf) RGB numeric value corresponding to color must be used
function RGBToInteger(rgbText) {
const [r,g,b] = rgbText.match(/\d+/g).map(Number);
return r + g * 256 + b * 65536;
}

let range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.Color);
border.Color = RGBToInteger("RGB(255,199,206)");
Border.ColorIndexProperty that returns or changes the border color of the specified range using index methodlet range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.ColorIndex);
border.ColorIndex = 1;
Border.LineStyleProperty that returns or changes the border type of the specified rangelet range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.LineStyle);
border.LineStyle = instance.Enums.XlLineStyle.xlContinuous;
Border.ThemeColorProperty that returns or changes the border theme color of the specified range using index methodlet range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.ThemeColor);
border.ThemeColor = 1;
Border.TintAndShadeProperty that returns or changes the brightness of the border of the specified rangelet range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.TintAndShade);
border.TintAndShade = 0.3;
Border.WeightProperty that returns or changes the thickness of the border of the specified rangelet range = instance.Application.ActiveSheet.Range("A1");
let border = range.Borders.Item(instance.Enums.XlBordersIndex.xlEdgeBottom);

console.log(border.Weight);
border.Weight = instance.Enums.XlBorderWeight.xlThick;
Range.BorderAroundFunction that specifies a border around the specified rangelet range = instance.Application.ActiveSheet.UsedRange;
let enums = instance.Enums;

range.BorderAround({
LineStyle: enums.XlLineStyle.xlDash,
Weight: enums.XlBorderWeight.xlThin
});

Format Management , Font Style , Text Alignment and Line Breaks , Conditional Formatting , Custom Formatting , Formatting Rendering Overview