Created
September 20, 2024 13:43
-
-
Save dfinke/f084beadbe2a6f119385359b2bc351d0 to your computer and use it in GitHub Desktop.
Create Excel bar chart using PowerShell by repeating symbols based on values with custom styling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = ConvertFrom-Csv @" | |
Name,UnitsSold | |
John,100 | |
Jane,200 | |
Tom,120 | |
Jane,300 | |
Jim,150 | |
Mary,250 | |
"@ | |
$xlFile = "$PSScriptRoot\spike.xlsx" | |
Remove-Item $xlFile -ErrorAction SilentlyContinue | |
$xlPkg = $data | Export-Excel -Path $xlFile -AutoSize -PassThru | |
Set-ExcelRange -Worksheet $xlPkg.Sheet1 -Range 'C1:C1' -Value 'Plot' | |
Set-ExcelRange -Worksheet $xlPkg.Sheet1 -Width 35 ` | |
-Range 'C2:C7' -Formula '=REPT("|",B2)' ` | |
-FontName 'Playbill' -FontColor "Green" | |
Close-ExcelPackage $xlPkg -Show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment