Skip to main content

Font Style (Font, Size, Color)

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

let font = range.Font;
Font.BoldProperty that returns or changes the bold state of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Bold);
font.Bold = true;
Font.ColorProperty that returns or changes the color of text
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 font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Color);
font.Color = RGBToInteger("RGB(255,199,206)");
Font.ColorIndexProperty that returns or changes the color of text using index methodlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.ColorIndex);
font.ColorIndex = 1;
Font.ItalicProperty that returns or changes the italic state of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Italic);
font.Italic = true;
Font.NameProperty that returns or changes the font name of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Name);
font.Name = "Calibri";
Font.SizeProperty that returns or changes the font size of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Size);
font.Size = 10;
Font.StrikethroughProperty that returns or changes the strikethrough state of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Strikethrough);
font.Strikethrough = true;
Font.SubscriptProperty that returns or changes the subscript state of textlet font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Subscript); font.Subscript = true;
Font.SuperscriptProperty that returns or changes the superscript state of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Superscript);
font.Superscript = true;
Font.ThemeColorProperty that returns or changes the theme color of text using index methodlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.ThemeColor);
font.ThemeColor = 1;
Font.TintAndShadeProperty that returns or changes the brightness of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.TintAndShade);
font.TintAndShade = 0.3;
Font.UnderlineProperty that returns or changes the underline state of textlet font = instance.Application.ActiveSheet.Range("A1").Font;

console.log(font.Underline);
font.Underline = instance.Enums.XlUnderlineStyle.xlUnderlineStyleSingle;

Format Management , Cell Background Color and Border , Text Alignment and Line Breaks , Conditional Formatting , Custom Formatting , Formatting Rendering Overview