This commit is contained in:
dfinke
2016-12-22 12:01:16 -05:00
parent 29e44e0aa1
commit 221bc5d215
3 changed files with 43 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ function Export-Excel {
Get-Service | Export-Excel "c:\temp\test.xlsx" -Show -IncludePivotTable -PivotRows status -PivotData @{status='count'}
#>
param(
[Parameter(Mandatory=$true)]
#[Parameter(Mandatory=$true)]
$Path,
[Parameter(ValueFromPipeline=$true)]
$TargetData,
@@ -51,7 +51,6 @@ function Export-Excel {
[Object[]]$ConditionalFormat,
[Object[]]$ConditionalText,
[Object[]]$ExcelChartDefinition,
# [Object[]]$CellStyle,
[ScriptBlock]$CellStyleSB,
[string[]]$HideSheet,
[Switch]$KillExcel,
@@ -59,7 +58,8 @@ function Export-Excel {
$StartRow=1,
$StartColumn=1,
[Switch]$PassThru,
[string]$Numberformat="General"
[string]$Numberformat="General",
[Switch]$Now
)
Begin {
@@ -70,7 +70,15 @@ function Export-Excel {
}
try {
if($Now) {
$Path=[System.IO.Path]::GetTempFileName() -replace "\.tmp",".xlsx"
$Show=$true
$AutoSize=$true
$AutoFilter=$true
}
$Path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
if (Test-Path $path) {
Write-Debug "File `"$Path`" already exists"
}