Files
ImportExcel/Set-CellStyle.ps1
2019-04-30 13:28:52 -07:00

16 lines
589 B
PowerShell

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope='Function', Target='Set*', Justification='Does not change system state')]
param()
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)
}