ExcelScript.ShapeFont interface
Represents the font attributes, such as font name, font size, and color, for a shape's TextRange
object.
Remarks
Examples
/**
* This sample sets the font of a shape to be bold.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first shape in the current worksheet.
const sheet = workbook.getActiveWorksheet();
const shape = sheet.getShapes()[0];
// Get the text font from the shape.
const text: ExcelScript.TextRange = shape.getTextFrame().getTextRange();
const shapeTextFont: ExcelScript.ShapeFont = text.getFont();
// Set the font to be bold.
shapeTextFont.setBold(true);
}
Methods
get |
Represents the bold status of font. Returns |
get |
HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns |
get |
Represents the italic status of font. Returns |
get |
Represents font name (e.g., "Calibri"). If the text is a Complex Script or East Asian language, this is the corresponding font name; otherwise it is the Latin font name. |
get |
Represents font size in points (e.g., 11). Returns |
get |
Type of underline applied to the font. Returns |
set |
Represents the bold status of font. Returns |
set |
HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns |
set |
Represents the italic status of font. Returns |
set |
Represents font name (e.g., "Calibri"). If the text is a Complex Script or East Asian language, this is the corresponding font name; otherwise it is the Latin font name. |
set |
Represents font size in points (e.g., 11). Returns |
set |
Type of underline applied to the font. Returns |
Method Details
getBold()
Represents the bold status of font. Returns null
if the TextRange
includes both bold and non-bold text fragments.
getBold(): boolean;
Returns
boolean
getColor()
HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns null
if the TextRange
includes text fragments with different colors.
getColor(): string;
Returns
string
getItalic()
Represents the italic status of font. Returns null
if the TextRange
includes both italic and non-italic text fragments.
getItalic(): boolean;
Returns
boolean
getName()
Represents font name (e.g., "Calibri"). If the text is a Complex Script or East Asian language, this is the corresponding font name; otherwise it is the Latin font name.
getName(): string;
Returns
string
getSize()
Represents font size in points (e.g., 11). Returns null
if the TextRange
includes text fragments with different font sizes.
getSize(): number;
Returns
number
getUnderline()
Type of underline applied to the font. Returns null
if the TextRange
includes text fragments with different underline styles. See ExcelScript.ShapeFontUnderlineStyle
for details.
getUnderline(): ShapeFontUnderlineStyle;
Returns
setBold(bold)
Represents the bold status of font. Returns null
if the TextRange
includes both bold and non-bold text fragments.
setBold(bold: boolean): void;
Parameters
- bold
-
boolean
Returns
void
setColor(color)
HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns null
if the TextRange
includes text fragments with different colors.
setColor(color: string): void;
Parameters
- color
-
string
Returns
void
setItalic(italic)
Represents the italic status of font. Returns null
if the TextRange
includes both italic and non-italic text fragments.
setItalic(italic: boolean): void;
Parameters
- italic
-
boolean
Returns
void
setName(name)
Represents font name (e.g., "Calibri"). If the text is a Complex Script or East Asian language, this is the corresponding font name; otherwise it is the Latin font name.
setName(name: string): void;
Parameters
- name
-
string
Returns
void
setSize(size)
Represents font size in points (e.g., 11). Returns null
if the TextRange
includes text fragments with different font sizes.
setSize(size: number): void;
Parameters
- size
-
number
Returns
void
setUnderline(underline)
Type of underline applied to the font. Returns null
if the TextRange
includes text fragments with different underline styles. See ExcelScript.ShapeFontUnderlineStyle
for details.
setUnderline(underline: ShapeFontUnderlineStyle): void;
Parameters
- underline
- ExcelScript.ShapeFontUnderlineStyle
Returns
void
Office Scripts