From a3c2a92e33b3ae480bfeae8c07fd4df038f8b6ef Mon Sep 17 00:00:00 2001 From: Brun Date: Wed, 20 Sep 2017 13:56:06 -0400 Subject: [PATCH 1/4] Header formatting fix when Title is used (Issue #182) --- Export-Excel.ps1 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index cfbcddc..f49d853 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -41,7 +41,7 @@ Function Export-Excel { '#,##0.00' # number with 2 decimal places and thousand separator and money symbol - '€#,##0.00' + '€#,##0.00' # percentage (1 = 100%, 0.01 = 1%) '0%' @@ -498,8 +498,14 @@ Function Export-Excel { } } - $startAddress=$ws.Dimension.Start.Address - $dataRange="{0}:{1}" -f $startAddress, $ws.Dimension.End.Address + if ($Title) { + $startAddress = "A2" + } + else { + $startAddress = $ws.Dimension.Start.Address + } + + $dataRange = "{0}:{1}" -f $startAddress, $ws.Dimension.End.Address Write-Debug "Data Range '$dataRange'" @@ -526,10 +532,6 @@ Function Export-Excel { $pivotTableDataName=$WorkSheetname + 'PivotTableData' - if ($Title) { - $startAddress = 'A2' - } - $pivotTable = $wsPivot.PivotTables.Add($wsPivot.Cells['A1'], $ws.Cells[$dataRange], $pivotTableDataName) if ($PivotRows) { @@ -607,7 +609,13 @@ Function Export-Excel { } } if ($BoldTopRow) { - $range=$ws.Dimension.Address -replace $ws.Dimension.Rows, '1' + if ($Title) { + $range = $ws.Dimension.Address -replace '\d+', '2' + } + else { + $range = $ws.Dimension.Address -replace '\d+', '1' + } + $ws.Cells[$range].Style.Font.Bold = $true } if ($AutoSize) { @@ -687,7 +695,7 @@ Function Export-Excel { $rule.Style.Font.Color.Color = $targetConditionalText.ConditionalTextColor $rule.Style.Fill.PatternType = $targetConditionalText.PatternType $rule.Style.Fill.BackgroundColor.Color = $targetConditionalText.BackgroundColor - } + } } if ($CellStyleSB) { From 5d700035822f005f7dfc132fd97be96b18d479f1 Mon Sep 17 00:00:00 2001 From: Brun Date: Mon, 2 Oct 2017 10:04:13 -0400 Subject: [PATCH 2/4] Title fixes --- Export-Excel.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index f49d853..98d9be9 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -515,6 +515,9 @@ Function Export-Excel { if (-not [String]::IsNullOrEmpty($TableName)) { $csr = $StartRow + if ($Title) { + $csr += 1 + } $csc = $StartColumn $cer = $ws.Dimension.End.Row $cec = $script:Header.Count From 58ae6845ffbfaf7f812de3684605bd2332f05662 Mon Sep 17 00:00:00 2001 From: Brun Date: Tue, 3 Oct 2017 08:28:37 -0400 Subject: [PATCH 3/4] Updated README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4209805..0e2b4bd 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfi ``` # What's new +#### 10/2/2017 +Fixed issues related to use of -Title parameter combined with column formatting parameters. +[Issue #182](https://github.com/dfinke/ImportExcel/issues/182) +[Issue #89](https://github.com/dfinke/ImportExcel/issues/89) + #### 9/12/2017 Version 4.0 released. From 409f69e91580e22f6ffaf2e355428de63bf3eeb1 Mon Sep 17 00:00:00 2001 From: Brun Date: Tue, 3 Oct 2017 08:29:10 -0400 Subject: [PATCH 4/4] Updated README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e2b4bd..2d63e9f 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfi # What's new #### 10/2/2017 Fixed issues related to use of -Title parameter combined with column formatting parameters. -[Issue #182](https://github.com/dfinke/ImportExcel/issues/182) -[Issue #89](https://github.com/dfinke/ImportExcel/issues/89) +- [Issue #182](https://github.com/dfinke/ImportExcel/issues/182) +- [Issue #89](https://github.com/dfinke/ImportExcel/issues/89) #### 9/12/2017 Version 4.0 released.