Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelText

Aliases: ExcelText
Module
PSWriteOffice
Aliases
ExcelText
Inputs
None

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: Default

Examples

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 optional
Applies bold text. An explicit false value clears bold; omission preserves the native value.
-Color OfficeColor optional
Text or rule colour expressed as a literal OfficeColor or theme role.
-Font String optional
Font family name.
-Italic SwitchParameter optional
Applies italic text. An explicit false value clears italic; omission preserves the native value.
-Size OfficeLength optional
Font size, interpreted as points for numbers; explicit physical units are accepted.
-Strikethrough SwitchParameter optional
Applies strikethrough; explicit false clears it.
-Text String requiredposition: 0
Comment text.
-Underline ExcelUnderlineStyle optional
Apply or clear underline styling across the target row span.
Possible values: Single, Double, SingleAccounting, DoubleAccounting
-VerticalAlignment ExcelVerticalTextAlignment optional
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.