The Add-ExcelChart cmdlet has various parameters to configure the X and Y axis. While configuring the Y-axis seems to work as expected, the X-axis behaves quite strangely as the example below shows.
`
$XL = Open-ExcelPackage -Path "Example2.xlsx" -Create
$Sheet = Add-WorkSheet -ExcelPackage $XL -WorksheetName "Example2"
for ($I = 1;$I -lt 8;$I++)
{
$Sheet.Cells[1,$I].Value = @(5, 10, 15, 20, 25, 30, 35)[$I - 1]
}
for ($I = 1;$I -lt 8;$I++)
{
$Sheet.Cells[2,$I].Value = @(18, 11, 23, 17, 12, 32, 12)[$I - 1]
}
$Chart = Add-ExcelChart -WorkSheet $Sheet -Row 8 -Column 1 -ChartType "LINE" -Title "Very Fancy Title" -passthru -YRange "A2:G2" -YMinValue 5 -YMaxValue 45 -YMajorUnit 10 -YMinorUnit 5
-XRange "A1:G1" #-XMinValue 0 -XMaxValue 45 -XMajorUnit 10 -XMinorUnit 5
#-YRange "A2:G2" -YMinValue 10 -YMaxValue 50 `
#-XRange "A1:G1" -XMinValue 0 -XMaxValue 50
Close-ExcelPackage -ExcelPackage $XL -Show
`
I've included a couple of lines of code that are commented out. These show some other parameters that have an effect but not a desirable one.
Having looked at the code for Add-ExcelChart I am fairly sure that the problem is in the EPPlus library but I thought I should mention it in case it is something that can be fixed elsewhere.
Best wishes.....
The Add-ExcelChart cmdlet has various parameters to configure the X and Y axis. While configuring the Y-axis seems to work as expected, the X-axis behaves quite strangely as the example below shows.
`
$XL = Open-ExcelPackage -Path "Example2.xlsx" -Create
$Sheet = Add-WorkSheet -ExcelPackage $XL -WorksheetName "Example2"
for ($I = 1;$I -lt 8;$I++)
{
$Sheet.Cells[1,$I].Value = @(5, 10, 15, 20, 25, 30, 35)[$I - 1]
}
for ($I = 1;$I -lt 8;$I++)
{
$Sheet.Cells[2,$I].Value = @(18, 11, 23, 17, 12, 32, 12)[$I - 1]
}
$Chart = Add-ExcelChart -WorkSheet $Sheet -Row 8 -Column 1 -ChartType "LINE" -Title "Very Fancy Title" -passthru
-YRange "A2:G2" -YMinValue 5 -YMaxValue 45 -YMajorUnit 10 -YMinorUnit 5-XRange "A1:G1" #-XMinValue 0 -XMaxValue 45 -XMajorUnit 10 -XMinorUnit 5
#-YRange "A2:G2" -YMinValue 10 -YMaxValue 50 `
#-XRange "A1:G1" -XMinValue 0 -XMaxValue 50
Close-ExcelPackage -ExcelPackage $XL -Show
`
I've included a couple of lines of code that are commented out. These show some other parameters that have an effect but not a desirable one.
Having looked at the code for Add-ExcelChart I am fairly sure that the problem is in the EPPlus library but I thought I should mention it in case it is something that can be fixed elsewhere.
Best wishes.....