Font Style (Font, Size, Color)
| API | Description | Example |
|---|---|---|
| Range.Font | Property that returns the font management object for the specified range | let range = instance.Application.ActiveSheet.Range("A1"); let font = range.Font; |
| Font.Bold | Property that returns or changes the bold state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Bold); font.Bold = true; |
| Font.Color | Property 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.ColorIndex | Property that returns or changes the color of text using index method | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.ColorIndex); font.ColorIndex = 1; |
| Font.Italic | Property that returns or changes the italic state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Italic); font.Italic = true; |
| Font.Name | Property that returns or changes the font name of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Name); font.Name = "Calibri"; |
| Font.Size | Property that returns or changes the font size of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Size); font.Size = 10; |
| Font.Strikethrough | Property that returns or changes the strikethrough state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Strikethrough); font.Strikethrough = true; |
| Font.Subscript | Property that returns or changes the subscript state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Subscript); font.Subscript = true; |
| Font.Superscript | Property that returns or changes the superscript state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Superscript); font.Superscript = true; |
| Font.ThemeColor | Property that returns or changes the theme color of text using index method | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.ThemeColor); font.ThemeColor = 1; |
| Font.TintAndShade | Property that returns or changes the brightness of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.TintAndShade); font.TintAndShade = 0.3; |
| Font.Underline | Property that returns or changes the underline state of text | let font = instance.Application.ActiveSheet.Range("A1").Font; console.log(font.Underline); font.Underline = instance.Enums.XlUnderlineStyle.xlUnderlineStyleSingle; |
Related Features
Format Management , Cell Background Color and Border , Text Alignment and Line Breaks , Conditional Formatting , Custom Formatting , Formatting Rendering Overview