API Reference

Cmdlet

Set-OfficeExcelColumnStyleByHeader

Aliases: ExcelColumnStyle, ExcelColumnStyleByHeader
Namespace PSWriteOffice
Aliases
ExcelColumnStyle ExcelColumnStyleByHeader
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

Applies common number, fill, font, and status styles to a worksheet column resolved by header text.

Remarks

Uses the OfficeIMO header resolver so scripts can style report columns without calculating column letters or ranges.

Examples

Authored help example

Format common report columns by header.

PS>


ExcelSheet 'Data' {
                Set-OfficeExcelColumnStyleByHeader -Header Revenue -Style Currency -CultureName en-US -AutoFit
                Set-OfficeExcelColumnStyleByHeader -Header Status -BackgroundByText @{ Ready = '#D4EDDA'; Blocked = '#F8D7DA' } -BoldByText Blocked
              }
        

Styles Revenue as currency and colors Status cells by their text.

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.

Syntax

Set-OfficeExcelColumnStyleByHeader [-Alignment <Left|Center|Right>] [-AutoFit] [-BackgroundByText <Hashtable>] [-BackgroundColor <String>] [-Bold] [-BoldByText <String[]>] [-CaseSensitive] [-CultureName <String>] [-Decimals <Int32>] [-FontColor <String>] [-FontColorByText <Hashtable>] -Header <String> [-IgnoreMissing] [-IncludeHeader] [-NumberFormat <String>] [-Pattern <String>] [-Style <Number>] [-Width <Nullable`1>] [<CommonParameters>]
#
Parameter set: Context

Parameters

Alignment String optionalposition: namedpipeline: Falsevalues: 3
Align cell content in the resolved column.
Possible values: Left, Center, Right
AutoFit SwitchParameter optionalposition: namedpipeline: False
Auto-fit the resolved column after applying styles.
BackgroundByText Hashtable optionalposition: namedpipeline: False
Background colors keyed by matching cell text.
BackgroundColor String optionalposition: namedpipeline: False
Apply a solid background color to the whole resolved column.
Bold SwitchParameter optionalposition: namedpipeline: False
Apply bold text to the whole resolved column.
BoldByText String[] optionalposition: namedpipeline: False
Values that should be bolded when the cell text matches.
CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching for text maps.
CultureName String optionalposition: namedpipeline: False
Culture used by currency formatting, such as en-US or pl-PL.
Decimals Int32 optionalposition: namedpipeline: False
Decimal places for number, percent, and currency styles.
FontColor String optionalposition: namedpipeline: False
Apply a font color to the whole resolved column.
FontColorByText Hashtable optionalposition: namedpipeline: False
Font colors keyed by matching cell text.
Header String requiredposition: 0pipeline: False
Header caption used to resolve the target column.
IgnoreMissing SwitchParameter optionalposition: namedpipeline: False
Do nothing when the header cannot be found instead of throwing.
IncludeHeader SwitchParameter optionalposition: namedpipeline: False
Include the header cell in the applied formatting.
NumberFormat String optionalposition: namedpipeline: False
Custom number format. Also used when Style is NumberFormat.
Pattern String optionalposition: namedpipeline: False
Date or DateTime number format pattern.
Style String optionalposition: namedpipeline: Falsevalues: 10
Preset number style to apply.
Possible values: Number, Integer, Percent, Currency, Date, DateTime, Time, DurationHours, Text, NumberFormat
Width Nullable`1 optionalposition: namedpipeline: False
Set the resolved column width.

Outputs

System.Object

Set-OfficeExcelColumnStyleByHeader [-Alignment <Left|Center|Right>] [-AutoFit] [-BackgroundByText <Hashtable>] [-BackgroundColor <String>] [-Bold] [-BoldByText <String[]>] [-CaseSensitive] [-CultureName <String>] [-Decimals <Int32>] -Document <ExcelDocument> [-FontColor <String>] [-FontColorByText <Hashtable>] -Header <String> [-IgnoreMissing] [-IncludeHeader] [-NumberFormat <String>] [-Pattern <String>] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-Style <Number>] [-Width <Nullable`1>] [<CommonParameters>]
#
Parameter set: Document

Parameters

Alignment String optionalposition: namedpipeline: Falsevalues: 3
Align cell content in the resolved column.
Possible values: Left, Center, Right
AutoFit SwitchParameter optionalposition: namedpipeline: False
Auto-fit the resolved column after applying styles.
BackgroundByText Hashtable optionalposition: namedpipeline: False
Background colors keyed by matching cell text.
BackgroundColor String optionalposition: namedpipeline: False
Apply a solid background color to the whole resolved column.
Bold SwitchParameter optionalposition: namedpipeline: False
Apply bold text to the whole resolved column.
BoldByText String[] optionalposition: namedpipeline: False
Values that should be bolded when the cell text matches.
CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching for text maps.
CultureName String optionalposition: namedpipeline: False
Culture used by currency formatting, such as en-US or pl-PL.
Decimals Int32 optionalposition: namedpipeline: False
Decimal places for number, percent, and currency styles.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
FontColor String optionalposition: namedpipeline: False
Apply a font color to the whole resolved column.
FontColorByText Hashtable optionalposition: namedpipeline: False
Font colors keyed by matching cell text.
Header String requiredposition: 0pipeline: False
Header caption used to resolve the target column.
IgnoreMissing SwitchParameter optionalposition: namedpipeline: False
Do nothing when the header cannot be found instead of throwing.
IncludeHeader SwitchParameter optionalposition: namedpipeline: False
Include the header cell in the applied formatting.
NumberFormat String optionalposition: namedpipeline: False
Custom number format. Also used when Style is NumberFormat.
Pattern String optionalposition: namedpipeline: False
Date or DateTime number format pattern.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.
Style String optionalposition: namedpipeline: Falsevalues: 10
Preset number style to apply.
Possible values: Number, Integer, Percent, Currency, Date, DateTime, Time, DurationHours, Text, NumberFormat
Width Nullable`1 optionalposition: namedpipeline: False
Set the resolved column width.

Outputs

System.Object