Cmdlet
Set-OfficeExcelColumnStyleByHeader
Applies common number, fill, font, and status styles to a worksheet column resolved by header text.
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>] [-PassThru] [-Pattern <String>] [-Style <OfficeExcelColumnStylePreset>] [-Width <Double>] [<CommonParameters>]#Parameter set:
ContextSet-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>] [-PassThru] [-Pattern <String>] [-Sheet <String>] [-SheetIndex <Int32>] [-Style <OfficeExcelColumnStylePreset>] [-Width <Double>] [<CommonParameters>]#Parameter set:
DocumentDescription
Uses the OfficeIMO header resolver so scripts can style report columns without calculating column letters or ranges.
Examples
Format common report columns by header.
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.
Parameters
- -Alignment OfficeExcelColumnAlignment
- 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.
- -PassThru SwitchParameter
- Emit the object created or changed by the command.
- -Pattern String
- Date or DateTime number format pattern.
- -Style OfficeExcelColumnStylePreset
- Preset number style to apply.
- Possible values:
Number,Integer,Percent,Currency,Date,DateTime,Time,DurationHours,Text,NumberFormat - -Width Double
- Set the resolved column width.
- -Document ExcelDocument
- Workbook to operate on outside the DSL context.
- -Sheet String
- Worksheet name when using Document.
- -SheetIndex Int32
- Worksheet index (0-based) when using Document.
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.