Merge pull request #228 from jeremytbrun/TitleFix

Title fix (Issues #182 and #89)
This commit is contained in:
Doug Finke
2017-10-03 09:54:49 -04:00
committed by GitHub
2 changed files with 25 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ Function Export-Excel {
'#,##0.00' '#,##0.00'
# number with 2 decimal places and thousand separator and money symbol # number with 2 decimal places and thousand separator and money symbol
'<EFBFBD>#,##0.00' '#,##0.00'
# percentage (1 = 100%, 0.01 = 1%) # percentage (1 = 100%, 0.01 = 1%)
'0%' '0%'
@@ -498,7 +498,13 @@ Function Export-Excel {
} }
} }
if ($Title) {
$startAddress = "A2"
}
else {
$startAddress = $ws.Dimension.Start.Address $startAddress = $ws.Dimension.Start.Address
}
$dataRange = "{0}:{1}" -f $startAddress, $ws.Dimension.End.Address $dataRange = "{0}:{1}" -f $startAddress, $ws.Dimension.End.Address
Write-Debug "Data Range '$dataRange'" Write-Debug "Data Range '$dataRange'"
@@ -509,6 +515,9 @@ Function Export-Excel {
if (-not [String]::IsNullOrEmpty($TableName)) { if (-not [String]::IsNullOrEmpty($TableName)) {
$csr = $StartRow $csr = $StartRow
if ($Title) {
$csr += 1
}
$csc = $StartColumn $csc = $StartColumn
$cer = $ws.Dimension.End.Row $cer = $ws.Dimension.End.Row
$cec = $script:Header.Count $cec = $script:Header.Count
@@ -526,10 +535,6 @@ Function Export-Excel {
$pivotTableDataName=$WorkSheetname + 'PivotTableData' $pivotTableDataName=$WorkSheetname + 'PivotTableData'
if ($Title) {
$startAddress = 'A2'
}
$pivotTable = $wsPivot.PivotTables.Add($wsPivot.Cells['A1'], $ws.Cells[$dataRange], $pivotTableDataName) $pivotTable = $wsPivot.PivotTables.Add($wsPivot.Cells['A1'], $ws.Cells[$dataRange], $pivotTableDataName)
if ($PivotRows) { if ($PivotRows) {
@@ -607,7 +612,13 @@ Function Export-Excel {
} }
} }
if ($BoldTopRow) { 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 $ws.Cells[$range].Style.Font.Bold = $true
} }
if ($AutoSize) { if ($AutoSize) {

View File

@@ -27,6 +27,11 @@ iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfi
``` ```
# What's new # 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/28/2017 (Version 4.0.1) #### 9/28/2017 (Version 4.0.1)
- Added a new parameter called `Password` to import password protected files - Added a new parameter called `Password` to import password protected files
- Added even more `Pester` tests for a more robust and bug free module - Added even more `Pester` tests for a more robust and bug free module