diff --git a/New-ExcelChart.ps1 b/New-ExcelChart.ps1 index 473979d..b298c07 100644 --- a/New-ExcelChart.ps1 +++ b/New-ExcelChart.ps1 @@ -219,7 +219,7 @@ function Add-ExcelChart { .PARAMETER NoLegend If specified, turns of display of the key. If you only have one data series it may be preferable to use the title to say what the chart is. .PARAMETER SeriesHeader - Specify explicit name(s) for the data series, which will appear in the legend/key + Specify explicit name(s) for the data series, which will appear in the legend/key. The contents of a cell can be specified in the from =Sheet9!Z10 . .PARAMETER LegendPosition Location of the key, either left, right, top, bottom or TopRight. .PARAMETER LegendSize @@ -349,7 +349,7 @@ function Add-ExcelChart { [Switch]$NoLegend, [Switch]$ShowCategory, [Switch]$ShowPercent, - $SeriesHeader, + [String[]]$SeriesHeader, [Switch]$TitleBold, [Int]$TitleSize , [String]$XAxisTitleText, @@ -388,8 +388,16 @@ function Add-ExcelChart { } else { for ($idx = 0; $idx -lt $chartDefCount; $idx += 1) { - $Series = $chart.Series.Add($YRange[$idx], $XRange) - if ($SeriesHeader.Count -gt 0) { $Series.Header = $SeriesHeader[$idx] } + if ($Yrange.count -eq $xrange.count) { + $Series = $chart.Series.Add($YRange[$idx], $XRange[$idx]) + } + else { + $Series = $chart.Series.Add($YRange[$idx], $XRange) + } + if ($SeriesHeader.Count -gt 0) { + if ($SeriesHeader[$idx] -match '^=') {$Series.HeaderAddress = $SeriesHeader[$idx] -replace '^=',''} + else {$Series.Header = $SeriesHeader[$idx] } + } else { $Series.Header = "Series $($idx)"} } } diff --git a/README.md b/README.md index 44c9557..aeb76b9 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,11 @@ Install-Module ImportExcel - Thank you to Conrad Agramont, Twitter: [@AGramont](https://twitter.com/@AGramont) for the `AddMultiWorkSheet.ps1` example. Much appreciated! - Fixed several more bugs where parametrs were ignored if passed a zero value +- Fixed bug where chart series headers could not come form a cell refernce (=Sheet1!Z10 now works as a header reference) +- Add-Chart will now allow a single X range, or as many X ranges as there are Y ranges. - Merge-MultipleSheets is more robust. - Set-ExcelRow and Set-ExcelColumn trap attempts to process a sheet with no rows/columns. -- Help has been proof-read . +- Help has been proof-read (thanks to Mrs @Jhoneill !). # What's new 5.3.4