/
diev
/
dfinke-ImportExcel
Обзор
Документация
Войти
/
diev
/
dfinke-ImportExcel
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Examples/ConditionalFormatting/SalesReportWithDatabar.ps1
25 строк
746 B
MikeyBronowski
Standardising examples
01 июл 2020, 23:04
01 июл 2020, 23:04
8a20963
Код
Авторство
О чём код?
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} #Get rid of pre-exisiting sheet $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx" Write-Verbose -Verbose -Message "Save location: $xlSourcefile" Remove-Item $xlSourcefile -ErrorAction Ignore $excel = @" Month,Sales Jan,1277 Feb,1003 Mar,1105 Apr,952 May,770 Jun,621 "@ | ConvertFrom-csv | Export-Excel -Path $xlSourcefile -WorkSheetname Sheet1 -AutoNameRange -PassThru $sheet = $excel.Workbook.Worksheets["Sheet1"] Add-ConditionalFormatting -Worksheet $sheet -Range "B1:B7" -DataBarColor LawnGreen Set-ExcelRange -Address $sheet.Cells["A8"] -Value "Total" Set-ExcelRange -Address $sheet.Cells["B8"] -Formula "=Sum(Sales)" Close-ExcelPackage $excel -Show