Fix Bug. AutoFilter with TableName corrupted file

Fix Bug, AutoFilter with TableName create corrupted Excel file.
https://github.com/dfinke/ImportExcel/issues/65
You now cannot set AutoFilter and TableName at the same time.
"-Now" will not auto add AutoFilter if TableName set.
This commit is contained in:
ili101
2017-10-05 00:02:06 +03:00
parent d1c3e7b23e
commit 06124e12e7

View File

@@ -194,7 +194,7 @@ Function Export-Excel {
https://github.com/dfinke/ImportExcel https://github.com/dfinke/ImportExcel
#> #>
[CmdLetBinding()] [CmdletBinding(DefaultParameterSetName='Default')]
Param( Param(
$Path, $Path,
[Parameter(ValueFromPipeline=$true)] [Parameter(ValueFromPipeline=$true)]
@@ -223,6 +223,7 @@ Function Export-Excel {
[Switch]$FreezeFirstColumn, [Switch]$FreezeFirstColumn,
[Switch]$FreezeTopRowFirstColumn, [Switch]$FreezeTopRowFirstColumn,
[Int[]]$FreezePane, [Int[]]$FreezePane,
[Parameter(ParameterSetName='Default')]
[Switch]$AutoFilter, [Switch]$AutoFilter,
[Switch]$BoldTopRow, [Switch]$BoldTopRow,
[Switch]$NoHeader, [Switch]$NoHeader,
@@ -240,8 +241,10 @@ Function Export-Excel {
else { else {
$true $true
} }
})] })]
[Parameter(ParameterSetName='Table')]
[String]$TableName, [String]$TableName,
[Parameter(ParameterSetName='Table')]
[OfficeOpenXml.Table.TableStyles]$TableStyle = 'Medium6', [OfficeOpenXml.Table.TableStyles]$TableStyle = 'Medium6',
[Object[]]$ExcelChartDefinition, [Object[]]$ExcelChartDefinition,
[String[]]$HideSheet, [String[]]$HideSheet,
@@ -386,7 +389,10 @@ Function Export-Excel {
$Path = [System.IO.Path]::GetTempFileName() -replace '\.tmp','.xlsx' $Path = [System.IO.Path]::GetTempFileName() -replace '\.tmp','.xlsx'
$Show = $true $Show = $true
$AutoSize = $true $AutoSize = $true
$AutoFilter = $true if (!$TableName)
{
$AutoFilter = $true
}
} }
$Path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path) $Path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)