Cmdlet
Add-OfficeExcelText
Adds a styled rich-text run to the enclosing cell or comment.
Syntax
Add-OfficeExcelText
[-Bold]
[-Color <OfficeColor>]
[-Font <String>]
[-Italic]
[-Size <OfficeLength>]
[-Strikethrough]
[-Text] <String>
[-Underline <Single| Double| SingleAccounting| DoubleAccounting>]
[-VerticalAlignment <Baseline| Superscript| Subscript>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Add a bold run to a cell
New-OfficeExcel -Path .\Status.xlsx {
ExcelSheet 'Summary' {
ExcelCell A1 {
ExcelText 'Owner: ' -Bold
ExcelText 'Infrastructure team'
}
}
}Builds a cell value from a bold label and plain text.
Highlight a status and add a footnote marker
Open-OfficeExcel -Path .\Reports\Migration.xlsx {
ExcelSheet 'Overview' {
ExcelCell B3 {
ExcelText 'Cutover risk: '
ExcelText 'High' -Bold -Color Danger -Size 12pt
ExcelText '1' -VerticalAlignment Superscript
}
ExcelCell B20 '1 Vendor patch not yet certified for production.'
}
}Colours the risk word by its theme role and adds a superscript reference to the notes below.
Parameters
- -Bold SwitchParameter
- Applies bold text. An explicit false value clears bold; omission preserves the native value.
- -Color OfficeColor
- Text or rule colour expressed as a literal OfficeColor or theme role.
- -Font String
- Font family name.
- -Italic SwitchParameter
- Applies italic text. An explicit false value clears italic; omission preserves the native value.
- -Size OfficeLength
- Font size, interpreted as points for numbers; explicit physical units are accepted.
- -Strikethrough SwitchParameter
- Applies strikethrough; explicit false clears it.
- -Text String
- Comment text.
- -Underline ExcelUnderlineStyle
- Apply or clear underline styling across the target row span.
- Possible values:
Single,Double,SingleAccounting,DoubleAccounting - -VerticalAlignment ExcelVerticalTextAlignment
- Normal, superscript or subscript positioning for the text run.
- Possible values:
Baseline,Superscript,Subscript
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.