Skip to content
Discussion options

You must be logged in to vote

Try this:

$xlSourcefile = "$PSScriptRoot\spike.xlsx"
Remove-Item $xlSourcefile -ErrorAction Ignore

$data = ConvertFrom-Csv @"
ID,Product,Quantity,Price,Total
12001,Nails,37,3.99,147.63
12002,Hammer,5,12.10,60.5
12003,Saw,12,15.37,184.44
12010,Drill,20,8,160
12011,Crowbar,7,23.48,164.36
"@

$excel = $data | Export-Excel -Path $xlSourcefile -AutoFilter -AutoNameRange -AutoSize -PassThru

$null = Add-Worksheet -ExcelPackage $excel -WorksheetName "Charts" -Activate

Add-ExcelChart -Worksheet $excel.Charts -YRange "Sheet1!Price" -XRange "Sheet1!Product" -Title "Item price" -NoLegend -Height 225
Add-ExcelChart -Worksheet $excel.Charts -YRange "Sheet1!Total" -XRange "Sheet1!Product" -Title "Tot…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Catalyst8487
Comment options

@dfinke
Comment options

Answer selected by Catalyst8487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants