Fix for color not casting strings in PS Core

This commit is contained in:
jhoneill
2018-10-22 17:21:09 +01:00
parent dcd730a4d1
commit c38648a654
11 changed files with 52 additions and 40 deletions

View File

@@ -106,11 +106,11 @@
#Text color for matching objects #Text color for matching objects
[Parameter(ParameterSetName = "NamedRule")] [Parameter(ParameterSetName = "NamedRule")]
[Alias("ForegroundColour")] [Alias("ForegroundColour")]
[System.Drawing.Color]$ForegroundColor, $ForegroundColor,
#Color for databar type charts #Color for databar type charts
[Parameter(Mandatory = $true, ParameterSetName = "DataBar")] [Parameter(Mandatory = $true, ParameterSetName = "DataBar")]
[Alias("DataBarColour")] [Alias("DataBarColour")]
[System.Drawing.Color]$DataBarColor, $DataBarColor,
#One of the three-icon set types (e.g. Traffic Lights) #One of the three-icon set types (e.g. Traffic Lights)
[Parameter(Mandatory = $true, ParameterSetName = "ThreeIconSet")] [Parameter(Mandatory = $true, ParameterSetName = "ThreeIconSet")]
[OfficeOpenXml.ConditionalFormatting.eExcelconditionalFormatting3IconsSetType]$ThreeIconsSet, [OfficeOpenXml.ConditionalFormatting.eExcelconditionalFormatting3IconsSetType]$ThreeIconsSet,
@@ -134,13 +134,13 @@
$ConditionValue2, $ConditionValue2,
#Background color for matching items #Background color for matching items
[Parameter(ParameterSetName = "NamedRule")] [Parameter(ParameterSetName = "NamedRule")]
[System.Drawing.Color]$BackgroundColor, $BackgroundColor,
#Background pattern for matching items #Background pattern for matching items
[Parameter(ParameterSetName = "NamedRule")] [Parameter(ParameterSetName = "NamedRule")]
[OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::None , [OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::None ,
#Secondary color when a background pattern requires it #Secondary color when a background pattern requires it
[Parameter(ParameterSetName = "NamedRule")] [Parameter(ParameterSetName = "NamedRule")]
[System.Drawing.Color]$PatternColor, $PatternColor,
#Sets the numeric format for matching items #Sets the numeric format for matching items
[Parameter(ParameterSetName = "NamedRule")] [Parameter(ParameterSetName = "NamedRule")]
$NumberFormat, $NumberFormat,
@@ -193,10 +193,12 @@
if (-not $worksheet -or $WorkSheet -isnot [OfficeOpenXml.ExcelWorksheet]) {write-warning "You need to provide a worksheet object." ; return} if (-not $worksheet -or $WorkSheet -isnot [OfficeOpenXml.ExcelWorksheet]) {write-warning "You need to provide a worksheet object." ; return}
#region create a rule of the right type #region create a rule of the right type
if ($RuleType -match 'IconSet$') {Write-warning -Message "You cannot configure a Icon-Set rule in this way; please use -$RuleType <SetName>." ; return} if ($RuleType -match 'IconSet$') {Write-warning -Message "You cannot configure a Icon-Set rule in this way; please use -$RuleType <SetName>." ; return}
if ($PSBoundParameters.ContainsKey("ThreeIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddThreeIconSet($Address , $ThreeIconsSet)} if ($PSBoundParameters.ContainsKey("DataBarColor" ) ) {if ($DataBarColor -is [string]) {$DataBarColor = [System.Drawing.Color]::$DataBarColor }
$rule = $WorkSheet.ConditionalFormatting.AddDatabar( $Address , $DataBarColor )
}
elseif ($PSBoundParameters.ContainsKey("ThreeIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddThreeIconSet($Address , $ThreeIconsSet)}
elseif ($PSBoundParameters.ContainsKey("FourIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddFourIconSet( $Address , $FourIconsSet )} elseif ($PSBoundParameters.ContainsKey("FourIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddFourIconSet( $Address , $FourIconsSet )}
elseif ($PSBoundParameters.ContainsKey("FiveIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddFiveIconSet( $Address , $FiveIconsSet )} elseif ($PSBoundParameters.ContainsKey("FiveIconsSet" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddFiveIconSet( $Address , $FiveIconsSet )}
elseif ($PSBoundParameters.ContainsKey("DataBarColor" ) ) {$rule = $WorkSheet.ConditionalFormatting.AddDatabar( $Address , $DataBarColor )}
else {$rule = ($WorkSheet.ConditionalFormatting)."Add$RuleType"($Address ) } else {$rule = ($WorkSheet.ConditionalFormatting)."Add$RuleType"($Address ) }
if ($Reverse) { if ($Reverse) {
if ($rule.type -match 'IconSet$' ) {$rule.reverse = $true} if ($rule.type -match 'IconSet$' ) {$rule.reverse = $true}
@@ -255,10 +257,13 @@
if ($PSBoundParameters.ContainsKey("Bold" ) ) {$rule.Style.Font.Bold = [boolean]$Bold } if ($PSBoundParameters.ContainsKey("Bold" ) ) {$rule.Style.Font.Bold = [boolean]$Bold }
if ($PSBoundParameters.ContainsKey("Italic" ) ) {$rule.Style.Font.Italic = [boolean]$Italic } if ($PSBoundParameters.ContainsKey("Italic" ) ) {$rule.Style.Font.Italic = [boolean]$Italic }
if ($PSBoundParameters.ContainsKey("StrikeThru" ) ) {$rule.Style.Font.Strike = [boolean]$StrikeThru } if ($PSBoundParameters.ContainsKey("StrikeThru" ) ) {$rule.Style.Font.Strike = [boolean]$StrikeThru }
if ($PSBoundParameters.ContainsKey("ForeGroundColor" ) ) {$rule.Style.Font.Color.color = $ForeGroundColor } if ($PSBoundParameters.ContainsKey("ForeGroundColor" ) ) {if ($ForeGroundColor -is [string]) {$ForeGroundColor = [System.Drawing.Color]::$ForeGroundColor }
if ($PSBoundParameters.ContainsKey("BackgroundColor" ) ) {$rule.Style.Fill.BackgroundColor.color = $BackgroundColor } $rule.Style.Font.Color.color = $ForeGroundColor }
if ($PSBoundParameters.ContainsKey("BackgroundColor" ) ) {if ($BackgroundColor -is [string]) {$BackgroundColor = [System.Drawing.Color]::$BackgroundColor }
$rule.Style.Fill.BackgroundColor.color = $BackgroundColor }
if ($PSBoundParameters.ContainsKey("BackgroundPattern") ) {$rule.Style.Fill.PatternType = $BackgroundPattern } if ($PSBoundParameters.ContainsKey("BackgroundPattern") ) {$rule.Style.Fill.PatternType = $BackgroundPattern }
if ($PSBoundParameters.ContainsKey("PatternColor" ) ) {$rule.Style.Fill.PatternColor.color = $PatternColor } if ($PSBoundParameters.ContainsKey("PatternColor" ) ) {if ($PatternColor -is [string]) {$PatternColor = [System.Drawing.Color]::$PatternColor }
$rule.Style.Fill.PatternColor.color = $PatternColor }
#endregion #endregion
#Allow further tweaking by returning the rule, if passthru specified #Allow further tweaking by returning the rule, if passthru specified
if ($Passthru) {$rule} if ($Passthru) {$rule}

View File

@@ -428,7 +428,7 @@
[OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'Solid', [OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'Solid',
[Switch]$TitleBold, [Switch]$TitleBold,
[Int]$TitleSize = 22, [Int]$TitleSize = 22,
[System.Drawing.Color]$TitleBackgroundColor, $TitleBackgroundColor,
[Switch]$IncludePivotTable, [Switch]$IncludePivotTable,
[String]$PivotTableName, [String]$PivotTableName,
[String[]]$PivotRows, [String[]]$PivotRows,
@@ -677,6 +677,7 @@
$ws.Cells[$Row, $StartColumn].Style.Font.Bold = $True $ws.Cells[$Row, $StartColumn].Style.Font.Bold = $True
} }
if ($TitleBackgroundColor ) { if ($TitleBackgroundColor ) {
if ($TitleBackgroundColor -is [string]) {$TitleBackgroundColor = [System.Drawing.Color]::$TitleBackgroundColor }
$ws.Cells[$Row, $StartColumn].Style.Fill.PatternType = $TitleFillPattern $ws.Cells[$Row, $StartColumn].Style.Fill.PatternType = $TitleFillPattern
$ws.Cells[$Row, $StartColumn].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor) $ws.Cells[$Row, $StartColumn].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor)
} }

View File

@@ -89,7 +89,7 @@
#Sets the fill pattern for the title cell. #Sets the fill pattern for the title cell.
[OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'Solid', [OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'Solid',
#Sets the cell background color for the title cell. #Sets the cell background color for the title cell.
[System.Drawing.Color]$TitleBackgroundColor, $TitleBackgroundColor,
#Sets the title in boldface type. #Sets the title in boldface type.
[Switch]$TitleBold, [Switch]$TitleBold,
#Sets the point size for the title. #Sets the point size for the title.
@@ -149,6 +149,7 @@
if ($TitleBold) {$destinationSheet.Cells[1, 1].Style.Font.Bold = $True } if ($TitleBold) {$destinationSheet.Cells[1, 1].Style.Font.Bold = $True }
#Can only set TitleBackgroundColor if TitleFillPattern is something other than None. #Can only set TitleBackgroundColor if TitleFillPattern is something other than None.
if ($TitleBackgroundColor -AND ($TitleFillPattern -ne 'None')) { if ($TitleBackgroundColor -AND ($TitleFillPattern -ne 'None')) {
if ($TitleBackgroundColor -is [string]) {$TitleBackgroundColor = [System.Drawing.Color]::$TitleBackgroundColor }
$destinationSheet.Cells[1, 1].Style.Fill.PatternType = $TitleFillPattern $destinationSheet.Cells[1, 1].Style.Fill.PatternType = $TitleFillPattern
$destinationSheet.Cells[1, 1].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor) $destinationSheet.Cells[1, 1].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor)
} }

View File

@@ -108,13 +108,13 @@
#Name of a column which is unique used to pair up rows from the refence and difference side, default is "Name". #Name of a column which is unique used to pair up rows from the refence and difference side, default is "Name".
$Key = "Name" , $Key = "Name" ,
#Sets the font color for the "key" field; this means you can filter by color to get only changed rows. #Sets the font color for the "key" field; this means you can filter by color to get only changed rows.
[System.Drawing.Color]$KeyFontColor = [System.Drawing.Color]::DarkRed , $KeyFontColor = [System.Drawing.Color]::DarkRed ,
#Sets the background color for changed rows. #Sets the background color for changed rows.
[System.Drawing.Color]$ChangeBackgroundColor = [System.Drawing.Color]::Orange, $ChangeBackgroundColor = [System.Drawing.Color]::Orange,
#Sets the background color for rows in the reference but deleted from the difference sheet. #Sets the background color for rows in the reference but deleted from the difference sheet.
[System.Drawing.Color]$DeleteBackgroundColor = [System.Drawing.Color]::LightPink, $DeleteBackgroundColor = [System.Drawing.Color]::LightPink,
#Sets the background color for rows not in the reference but added to the difference sheet. #Sets the background color for rows not in the reference but added to the difference sheet.
[System.Drawing.Color]$AddBackgroundColor = [System.Drawing.Color]::PaleGreen, $AddBackgroundColor = [System.Drawing.Color]::PaleGreen,
#if specified, hides the rows in the spreadsheet that are equal and only shows changes, added or deleted rows. #if specified, hides the rows in the spreadsheet that are equal and only shows changes, added or deleted rows.
[switch]$HideEqual , [switch]$HideEqual ,
#If specified, outputs the data to the pipeline (you can add -WhatIf so the command only outputs to the pipeline). #If specified, outputs the data to the pipeline (you can add -WhatIf so the command only outputs to the pipeline).
@@ -402,13 +402,13 @@ Function Merge-MultipleSheets {
#Name of a column which is unique used to pair up rows from the reference and difference sides, default is "Name". #Name of a column which is unique used to pair up rows from the reference and difference sides, default is "Name".
$Key = "Name" , $Key = "Name" ,
#Sets the font color for the Key field; this means you can filter by color to get only changed rows. #Sets the font color for the Key field; this means you can filter by color to get only changed rows.
[System.Drawing.Color]$KeyFontColor = [System.Drawing.Color]::Red, $KeyFontColor = [System.Drawing.Color]::Red,
#Sets the background color for changed rows. #Sets the background color for changed rows.
[System.Drawing.Color]$ChangeBackgroundColor = [System.Drawing.Color]::Orange, $ChangeBackgroundColor = [System.Drawing.Color]::Orange,
#Sets the background color for rows in the reference but deleted from the difference sheet. #Sets the background color for rows in the reference but deleted from the difference sheet.
[System.Drawing.Color]$DeleteBackgroundColor = [System.Drawing.Color]::LightPink, $DeleteBackgroundColor = [System.Drawing.Color]::LightPink,
#Sets the background color for rows not in the reference but added to the difference sheet. #Sets the background color for rows not in the reference but added to the difference sheet.
[System.Drawing.Color]$AddBackgroundColor = [System.Drawing.Color]::Orange, $AddBackgroundColor = [System.Drawing.Color]::Orange,
#If specified, hides the columns in the spreadsheet that contain the row numbers. #If specified, hides the columns in the spreadsheet that contain the row numbers.
[switch]$HideRowNumbers , [switch]$HideRowNumbers ,
#If specified, outputs the data to the pipeline (you can add -whatif so it the command only outputs to the pipeline). #If specified, outputs the data to the pipeline (you can add -whatif so it the command only outputs to the pipeline).

View File

@@ -49,8 +49,8 @@ function New-ConditionalText {
[Alias("ConditionValue")] [Alias("ConditionValue")]
$Text, $Text,
[Alias("ForeGroundColor")] [Alias("ForeGroundColor")]
[System.Drawing.Color]$ConditionalTextColor=[System.Drawing.Color]::DarkRed, $ConditionalTextColor=[System.Drawing.Color]::DarkRed,
[System.Drawing.Color]$BackgroundColor=[System.Drawing.Color]::LightPink, $BackgroundColor=[System.Drawing.Color]::LightPink,
[String]$Range, [String]$Range,
[OfficeOpenXml.Style.ExcelFillStyle]$PatternType=[OfficeOpenXml.Style.ExcelFillStyle]::Solid, [OfficeOpenXml.Style.ExcelFillStyle]$PatternType=[OfficeOpenXml.Style.ExcelFillStyle]::Solid,
[ValidateSet( [ValidateSet(

View File

@@ -196,7 +196,7 @@
[OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'None', [OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'None',
[Switch]$TitleBold, [Switch]$TitleBold,
[Int]$TitleSize = 22, [Int]$TitleSize = 22,
[System.Drawing.Color]$TitleBackgroundColor, $TitleBackgroundColor,
[String]$Password, [String]$Password,
[Hashtable]$PivotTableDefinition, [Hashtable]$PivotTableDefinition,
[Switch]$IncludePivotTable, [Switch]$IncludePivotTable,

View File

@@ -4,9 +4,9 @@
$Row, $Row,
$LastColumn, $LastColumn,
[OfficeOpenXml.Style.ExcelFillStyle]$Pattern, [OfficeOpenXml.Style.ExcelFillStyle]$Pattern,
[System.Drawing.Color]$Color $Color
) )
if ($Color -is [string]) {$Color = [System.Drawing.Color]::$Color }
$t=$WorkSheet.Cells["A$($Row):$($LastColumn)$($Row)"] $t=$WorkSheet.Cells["A$($Row):$($LastColumn)$($Row)"]
$t.Style.Fill.PatternType=$Pattern $t.Style.Fill.PatternType=$Pattern
$t.Style.Fill.BackgroundColor.SetColor($Color) $t.Style.Fill.BackgroundColor.SetColor($Color)

View File

@@ -71,7 +71,7 @@
#Style of border to draw around the row. #Style of border to draw around the row.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround,
#Colour for the text - if none specified it will be left as it it is. #Colour for the text - if none specified it will be left as it it is.
[System.Drawing.Color]$FontColor, $FontColor,
#Make text bold; use -Bold:$false to remove bold. #Make text bold; use -Bold:$false to remove bold.
[Switch]$Bold, [Switch]$Bold,
#Make text italic; use -Italic:$false to remove italic. #Make text italic; use -Italic:$false to remove italic.
@@ -89,12 +89,12 @@
#Point size for the text. #Point size for the text.
[float]$FontSize, [float]$FontSize,
#Change background color. #Change background color.
[System.Drawing.Color]$BackgroundColor, $BackgroundColor,
#Background pattern - "Solid" by default. #Background pattern - "Solid" by default.
[OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid , [OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid ,
#Secondary color for background pattern. #Secondary color for background pattern.
[Alias("PatternColour")] [Alias("PatternColour")]
[System.Drawing.Color]$PatternColor, $PatternColor,
#Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping. #Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping.
[Switch]$WrapText, [Switch]$WrapText,
#Position cell contents to Left, Right, Center etc. Default is "General". #Position cell contents to Left, Right, Center etc. Default is "General".

View File

@@ -62,7 +62,7 @@
#Style of border to draw around the row. #Style of border to draw around the row.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround,
#Color of the border. #Color of the border.
[System.Drawing.Color]$BorderColor=[System.Drawing.Color]::Black, $BorderColor=[System.Drawing.Color]::Black,
#Style for the bottom border. #Style for the bottom border.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderBottom, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderBottom,
#Style for the top border. #Style for the top border.
@@ -72,7 +72,7 @@
#Style for the right border. #Style for the right border.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderRight, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderRight,
#Color for the text - if none specified it will be left as it it is. #Color for the text - if none specified it will be left as it it is.
[System.Drawing.Color]$FontColor, $FontColor,
#Make text bold; use -Bold:$false to remove bold. #Make text bold; use -Bold:$false to remove bold.
[Switch]$Bold, [Switch]$Bold,
#Make text italic; use -Italic:$false to remove italic. #Make text italic; use -Italic:$false to remove italic.
@@ -90,12 +90,12 @@
#Point size for the text. #Point size for the text.
[float]$FontSize, [float]$FontSize,
#Change background color. #Change background color.
[System.Drawing.Color]$BackgroundColor, $BackgroundColor,
#Background pattern - solid by default. #Background pattern - solid by default.
[OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid , [OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid ,
#Secondary color for background pattern. #Secondary color for background pattern.
[Alias("PatternColour")] [Alias("PatternColour")]
[System.Drawing.Color]$PatternColor, $PatternColor,
#Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping. #Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping.
[Switch]$WrapText, [Switch]$WrapText,
#Position cell contents to Left, Right, Center etc. default is 'General'. #Position cell contents to Left, Right, Center etc. default is 'General'.

View File

@@ -45,7 +45,7 @@
#Style of border to draw around the range. #Style of border to draw around the range.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderAround,
#Color of the border. #Color of the border.
[System.Drawing.Color]$BorderColor=[System.Drawing.Color]::Black, $BorderColor=[System.Drawing.Color]::Black,
#Style for the bottom border. #Style for the bottom border.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderBottom, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderBottom,
#Style for the top border. #Style for the top border.
@@ -55,7 +55,7 @@
#Style for the right border. #Style for the right border.
[OfficeOpenXml.Style.ExcelBorderStyle]$BorderRight, [OfficeOpenXml.Style.ExcelBorderStyle]$BorderRight,
#Colour for the text - if none is specified it will be left as it is. #Colour for the text - if none is specified it will be left as it is.
[System.Drawing.Color]$FontColor, $FontColor,
#Value for the cell. #Value for the cell.
$Value, $Value,
#Formula for the cell. #Formula for the cell.
@@ -81,12 +81,12 @@
#Point size for the text. #Point size for the text.
[float]$FontSize, [float]$FontSize,
#Change background color. #Change background color.
[System.Drawing.Color]$BackgroundColor, $BackgroundColor,
#Background pattern - Solid by default. #Background pattern - Solid by default.
[OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid , [OfficeOpenXml.Style.ExcelFillStyle]$BackgroundPattern = [OfficeOpenXml.Style.ExcelFillStyle]::Solid ,
#Secondary color for background pattern. #Secondary color for background pattern.
[Alias("PatternColour")] [Alias("PatternColour")]
[System.Drawing.Color]$PatternColor, $PatternColor,
#Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping. #Turn on Text-Wrapping; use -WrapText:$false to turn off wrapping.
[Switch]$WrapText, [Switch]$WrapText,
#Position cell contents to Left, Right, Center etc. default is 'General'. #Position cell contents to Left, Right, Center etc. default is 'General'.
@@ -150,6 +150,7 @@
$Range.Style.Font.VerticalAlign = $FontShift $Range.Style.Font.VerticalAlign = $FontShift
} }
if ($PSBoundParameters.ContainsKey('FontColor')){ if ($PSBoundParameters.ContainsKey('FontColor')){
if ($FontColor -is [string]) {$FontColor = [System.Drawing.Color]::$FontColor }
$Range.Style.Font.Color.SetColor( $FontColor) $Range.Style.Font.Color.SetColor( $FontColor)
} }
if ($PSBoundParameters.ContainsKey('TextRotation')) { if ($PSBoundParameters.ContainsKey('TextRotation')) {
@@ -179,6 +180,7 @@
if ($PSBoundParameters.ContainsKey('NumberFormat')) { if ($PSBoundParameters.ContainsKey('NumberFormat')) {
$Range.Style.Numberformat.Format = (Expand-NumberFormat $NumberFormat) $Range.Style.Numberformat.Format = (Expand-NumberFormat $NumberFormat)
} }
if ($BorderColor -is [string]) {$BorderColor = [System.Drawing.Color]::$BorderColor }
if ($PSBoundParameters.ContainsKey('BorderAround')) { if ($PSBoundParameters.ContainsKey('BorderAround')) {
$Range.Style.Border.BorderAround($BorderAround, $BorderColor) $Range.Style.Border.BorderAround($BorderAround, $BorderColor)
} }
@@ -200,8 +202,10 @@
} }
if ($PSBoundParameters.ContainsKey('BackgroundColor')) { if ($PSBoundParameters.ContainsKey('BackgroundColor')) {
$Range.Style.Fill.PatternType = $BackgroundPattern $Range.Style.Fill.PatternType = $BackgroundPattern
if ($BackgroundColor -is [string]) {$BackgroundColor = [System.Drawing.Color]::$BackgroundColor }
$Range.Style.Fill.BackgroundColor.SetColor($BackgroundColor) $Range.Style.Fill.BackgroundColor.SetColor($BackgroundColor)
if ($PatternColor) { if ($PatternColor) {
if ($PatternColor -is [string]) {$PatternColor = [System.Drawing.Color]::$PatternColor }
$Range.Style.Fill.PatternColor.SetColor( $PatternColor) $Range.Style.Fill.PatternColor.SetColor( $PatternColor)
} }
} }

View File

@@ -91,15 +91,15 @@
#The row from where we start to import data: all rows above the start row are disregarded. By default, this is the first row. #The row from where we start to import data: all rows above the start row are disregarded. By default, this is the first row.
[int]$Startrow = 1, [int]$Startrow = 1,
#If specified, highlights all the cells - so you can make Equal cells one color, and Different cells another. #If specified, highlights all the cells - so you can make Equal cells one color, and Different cells another.
[System.Drawing.Color]$AllDataBackgroundColor, $AllDataBackgroundColor,
#If specified, highlights the rows with differences. #If specified, highlights the rows with differences.
[System.Drawing.Color]$BackgroundColor, $BackgroundColor,
#If specified identifies the tabs which contain difference rows (ignored if -BackgroundColor is omitted). #If specified identifies the tabs which contain difference rows (ignored if -BackgroundColor is omitted).
[System.Drawing.Color]$TabColor, $TabColor,
#Name of a column which is unique and will be used to add a row to the DIFF object, defaults to "Name". #Name of a column which is unique and will be used to add a row to the DIFF object, defaults to "Name".
$Key = "Name" , $Key = "Name" ,
#If specified, highlights the DIFF columns in rows which have the same key. #If specified, highlights the DIFF columns in rows which have the same key.
[System.Drawing.Color]$FontColor, $FontColor,
#If specified, opens the Excel workbooks instead of outputting the diff to the console (unless -PassThru is also specified). #If specified, opens the Excel workbooks instead of outputting the diff to the console (unless -PassThru is also specified).
[Switch]$Show, [Switch]$Show,
#If specified, the command tries to the show the DIFF in a Grid-View and not on the console. (unless-PassThru is also specified). This works best with few columns selected, and requires a key. #If specified, the command tries to the show the DIFF in a Grid-View and not on the console. (unless-PassThru is also specified). This works best with few columns selected, and requires a key.
@@ -182,6 +182,7 @@
Set-Format -WorkSheet $ws -Range $range -BackgroundColor $BackgroundColor Set-Format -WorkSheet $ws -Range $range -BackgroundColor $BackgroundColor
} }
if ($TabColor) { if ($TabColor) {
if ($TabColor -is [string]) {$TabColor = [System.Drawing.Color]::$TabColor }
foreach ($tab in ($file.group._sheet | Select-Object -Unique)) { foreach ($tab in ($file.group._sheet | Select-Object -Unique)) {
$xl.Workbook.Worksheets[$tab].TabColor = $TabColor $xl.Workbook.Worksheets[$tab].TabColor = $TabColor
} }