mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-14 23:33:18 +00:00
Fix databar example
This commit is contained in:
@@ -299,6 +299,8 @@
|
|||||||
It then uses the package object to apply formatting, and then saves the workbook and disposes of the object before loading the document in Excel.
|
It then uses the package object to apply formatting, and then saves the workbook and disposes of the object before loading the document in Excel.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
|
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
|
||||||
|
|
||||||
$excel = Get-Process | Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS | Export-Excel -Path .\test.xlsx -ClearSheet -WorkSheetname "Processes" -PassThru
|
$excel = Get-Process | Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS | Export-Excel -Path .\test.xlsx -ClearSheet -WorkSheetname "Processes" -PassThru
|
||||||
$sheet = $excel.Workbook.Worksheets["Processes"]
|
$sheet = $excel.Workbook.Worksheets["Processes"]
|
||||||
$sheet.Column(1) | Set-Format -Bold -AutoFit
|
$sheet.Column(1) | Set-Format -Bold -AutoFit
|
||||||
@@ -309,7 +311,7 @@
|
|||||||
Set-Format -Address $sheet.Row(1) -Bold -HorizontalAlignment Center
|
Set-Format -Address $sheet.Row(1) -Bold -HorizontalAlignment Center
|
||||||
Add-ConditionalFormatting -WorkSheet $sheet -Range "D2:D1048576" -DataBarColor Red
|
Add-ConditionalFormatting -WorkSheet $sheet -Range "D2:D1048576" -DataBarColor Red
|
||||||
Add-ConditionalFormatting -WorkSheet $sheet -Range "G2:G1048576" -RuleType GreaterThan -ConditionValue "104857600" -ForeGroundColor Red
|
Add-ConditionalFormatting -WorkSheet $sheet -Range "G2:G1048576" -RuleType GreaterThan -ConditionValue "104857600" -ForeGroundColor Red
|
||||||
foreach ($c in 5..9) {Set-Format $sheet.Column($c) -AutoFit }
|
foreach ($c in 5..9) {Set-Format -Address $sheet.Column($c) -AutoFit }
|
||||||
Export-Excel -ExcelPackage $excel -WorkSheetname "Processes" -IncludePivotChart -ChartType ColumnClustered -NoLegend -PivotRows company -PivotData @{'Name'='Count'} -Show
|
Export-Excel -ExcelPackage $excel -WorkSheetname "Processes" -IncludePivotChart -ChartType ColumnClustered -NoLegend -PivotRows company -PivotData @{'Name'='Count'} -Show
|
||||||
|
|
||||||
This a more sophisticated version of the previous example showing different ways of using Set-Format, and also adding conditional formatting.
|
This a more sophisticated version of the previous example showing different ways of using Set-Format, and also adding conditional formatting.
|
||||||
@@ -713,7 +715,7 @@
|
|||||||
$tbl = $ws.Tables.Add($targetRange, $TableName)
|
$tbl = $ws.Tables.Add($targetRange, $TableName)
|
||||||
$tbl.TableStyle = $TableStyle
|
$tbl.TableStyle = $TableStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
$PivotTableStartCell = "A1"
|
$PivotTableStartCell = "A1"
|
||||||
if($PivotFilter) {$PivotTableStartCell = "A3"}
|
if($PivotFilter) {$PivotTableStartCell = "A3"}
|
||||||
|
|
||||||
@@ -1014,7 +1016,7 @@
|
|||||||
write-error "The -ReZip parameter requires .NET Framework 4.5 or later to be installed. Recommend to install Powershell v4+"
|
write-error "The -ReZip parameter requires .NET Framework 4.5 or later to be installed. Recommend to install Powershell v4+"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
$TempZipPath = Join-Path -path ([System.IO.Path]::GetTempPath()) -ChildPath ([System.IO.Path]::GetRandomFileName())
|
$TempZipPath = Join-Path -path ([System.IO.Path]::GetTempPath()) -ChildPath ([System.IO.Path]::GetRandomFileName())
|
||||||
[io.compression.zipfile]::ExtractToDirectory($pkg.File,$TempZipPath) | Out-Null
|
[io.compression.zipfile]::ExtractToDirectory($pkg.File,$TempZipPath) | Out-Null
|
||||||
Remove-Item $pkg.File -Force
|
Remove-Item $pkg.File -Force
|
||||||
|
|||||||
Reference in New Issue
Block a user