Skip to content

Configuring X-Axis on a line chart #1722

Open

Description

@ccx004B

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.....

Activity

  1. dfinke commented on Oct 7, 2025

    @dfinke
    Owner

    @ccx004B If you want to pull the fix and try it locally - let me know how it goes. Looke at it at a glance.
    I'm a tad suspicious that it has the xml tags. Not sure if that is the "fix" it did or was just reporting.

    If it has legs, I'll investigate further.

  2. ccx004B commented on Oct 22, 2025

    @ccx004B
    Author
  3. dfinke commented on Oct 22, 2025

    @dfinke
    Owner

    @ccx004B all good. Axis were a challenge when I intially wired them up. Thanks for trying out the change. I asked the AI Copilot to try a fix. I didn't give it an direction, figured it was woth a shot.

    If I can, I'll go deeper.

  4. ccx004B commented on Oct 22, 2025

    @ccx004B
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions