From 6c449bd9cef239e78b6d6c08e49e231945f75bb8 Mon Sep 17 00:00:00 2001 From: dfinke Date: Wed, 4 Jul 2018 19:15:34 -0400 Subject: [PATCH] Added sales report with databar --- .../SalesReportWithDatabar.ps1 | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Examples/ConditionalFormatting/SalesReportWithDatabar.ps1 diff --git a/Examples/ConditionalFormatting/SalesReportWithDatabar.ps1 b/Examples/ConditionalFormatting/SalesReportWithDatabar.ps1 new file mode 100644 index 0000000..7569f45 --- /dev/null +++ b/Examples/ConditionalFormatting/SalesReportWithDatabar.ps1 @@ -0,0 +1,23 @@ +try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} + +Remove-Item -Path .\test.xlsx -ErrorAction Ignore + +$excel = $( + New-PSItem Jan 1277 (echo Month Sales) + New-PSItem Feb 1003 + New-PSItem Mar 1105 + New-PSItem Apr 952 + New-PSItem May 770 + New-PSItem Jun 621 +) | Export-Excel .\test.xlsx -PassThru -AutoNameRange + +$sheet = $excel.Workbook.Worksheets["Sheet1"] + +Add-ConditionalFormatting -WorkSheet $sheet -Range "B1:B7" -DataBarColor LawnGreen + +$targetRow = $sheet.dimension.Rows + 1 + +Set-Format -Address $sheet.Cells["A$($targetRow)"] -Value "Total" +Set-Format -Address $sheet.Cells["B$($targetRow)"] -Formula "=Sum(Sales)" + +Close-ExcelPackage $excel -Show \ No newline at end of file