Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
ExcelScript.ShapeFont interface
- Package:
- ExcelScript
Represents the font attributes, such as font name, font size, and color, for a shape's TextRange object.
Remarks
Used by
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
| getBold() | Represents the bold status of font. Returns |
| getColor() | HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns |
| getItalic() | Represents the italic status of font. Returns |
| 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. |
| getSize() | Represents font size in points (e.g., 11). Returns |
| getUnderline() | Type of underline applied to the font. Returns |
| setBold(bold) | Represents the bold status of font. Returns |
| setColor(color) | HTML color code representation of the text color (e.g., "#FF0000" represents red). Returns |
| setItalic(italic) | Represents the italic status of font. Returns |
| 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. |
| setSize(size) | Represents font size in points (e.g., 11). Returns |
| setUnderline(underline) | 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
Feedback
Was this page helpful?
