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