Set-CellStyle.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
function Set-CellStyle {
    param(
        $WorkSheet,
        $Row,
        $LastColumn,
        [OfficeOpenXml.Style.ExcelFillStyle]$Pattern,
        $Color
    )
    if ($Color -is [string])         {$Color = [System.Drawing.Color]::$Color }
    $t=$WorkSheet.Cells["A$($Row):$($LastColumn)$($Row)"]
    $t.Style.Fill.PatternType=$Pattern
    $t.Style.Fill.BackgroundColor.SetColor($Color)
}