mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-11 05:43:17 +00:00
Updated Title related parameters
This commit is contained in:
@@ -21,7 +21,7 @@ function Export-Excel {
|
|||||||
[string]$WorkSheetname="Sheet1",
|
[string]$WorkSheetname="Sheet1",
|
||||||
[string]$Title,
|
[string]$Title,
|
||||||
[OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern="None",
|
[OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern="None",
|
||||||
[bool]$TitleBold,
|
[Switch]$TitleBold,
|
||||||
[int]$TitleSize=22,
|
[int]$TitleSize=22,
|
||||||
[System.Drawing.Color]$TitleBackgroundColor,
|
[System.Drawing.Color]$TitleBackgroundColor,
|
||||||
[string[]]$PivotRows,
|
[string[]]$PivotRows,
|
||||||
@@ -90,11 +90,20 @@ function Export-Excel {
|
|||||||
$ws.Cells[$Row, $StartColumn].Value = $Title
|
$ws.Cells[$Row, $StartColumn].Value = $Title
|
||||||
|
|
||||||
$ws.Cells[$Row, $StartColumn].Style.Font.Size = $TitleSize
|
$ws.Cells[$Row, $StartColumn].Style.Font.Size = $TitleSize
|
||||||
$ws.Cells[$Row, $StartColumn].Style.Font.Bold = $TitleBold
|
if ($TitleBold) {
|
||||||
|
#set title to Bold if -TitleBold was specified.
|
||||||
|
#Otherwise the default will be unbolded.
|
||||||
|
$ws.Cells[$Row, $StartColumn].Style.Font.Bold = $True
|
||||||
|
}
|
||||||
$ws.Cells[$Row, $StartColumn].Style.Fill.PatternType = $TitleFillPattern
|
$ws.Cells[$Row, $StartColumn].Style.Fill.PatternType = $TitleFillPattern
|
||||||
if($TitleBackgroundColor) {
|
|
||||||
|
#can only set TitleBackgroundColor if TitleFillPattern is something other than None
|
||||||
|
if($TitleBackgroundColor -AND ($TitleFillPattern -ne "None")) {
|
||||||
$ws.Cells[$Row, $StartColumn].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor)
|
$ws.Cells[$Row, $StartColumn].Style.Fill.BackgroundColor.SetColor($TitleBackgroundColor)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "Title Background Color ignored. You must set the TitleFillPattern parameter to a value other than 'None'. Try 'Solid'."
|
||||||
|
}
|
||||||
|
|
||||||
$Row += 1
|
$Row += 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user