Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title fix (Issues #182 and #89) #228

Merged
merged 5 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions Export-Excel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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%'
Expand Down Expand Up @@ -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'"

Expand All @@ -509,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
Expand All @@ -526,10 +535,6 @@ Function Export-Excel {

$pivotTableDataName=$WorkSheetname + 'PivotTableData'

if ($Title) {
$startAddress = 'A2'
}

$pivotTable = $wsPivot.PivotTables.Add($wsPivot.Cells['A1'], $ws.Cells[$dataRange], $pivotTableDataName)

if ($PivotRows) {
Expand Down Expand Up @@ -607,7 +612,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) {
Expand Down Expand Up @@ -687,7 +698,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) {
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/28/2017 (Version 4.0.1)
- Added a new parameter called `Password` to import password protected files
- Added even more `Pester` tests for a more robust and bug free module
Expand Down