mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-21 02:33:22 +00:00
sync export-excel to 321699e spec.
This commit is contained in:
@@ -202,7 +202,7 @@
|
|||||||
if it is a data table don't do foreach on it (slow) - put the whole table in and set dates on date columns,
|
if it is a data table don't do foreach on it (slow) - put the whole table in and set dates on date columns,
|
||||||
set things up for the end block, and skip the process block #>
|
set things up for the end block, and skip the process block #>
|
||||||
if ($InputObject -is [System.Data.DataTable]) {
|
if ($InputObject -is [System.Data.DataTable]) {
|
||||||
#don't leave caller with a renamed table, save the name and set it back later
|
#Change TableName if $TableName is non-empty; don't leave caller with a renamed table!
|
||||||
$orginalTableName = $InputObject.TableName
|
$orginalTableName = $InputObject.TableName
|
||||||
if ($TableName) {
|
if ($TableName) {
|
||||||
$InputObject.TableName = $TableName
|
$InputObject.TableName = $TableName
|
||||||
@@ -211,8 +211,8 @@
|
|||||||
Write-Warning "Table name $($InputObject.TableName) is not unique, adding '_' to it "
|
Write-Warning "Table name $($InputObject.TableName) is not unique, adding '_' to it "
|
||||||
$InputObject.TableName += "_"
|
$InputObject.TableName += "_"
|
||||||
}
|
}
|
||||||
if ($TableName -or $PSBoundParameters.ContainsKey("TableStyle")) {
|
#Insert as a table, if Tablestyle didn't arrive as a default, or $TableName non-null - even if empty
|
||||||
$TableName = $null
|
if ($null -ne $TableName -or $PSBoundParameters.ContainsKey("TableStyle")) {
|
||||||
$null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader),$TableStyle )
|
$null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader),$TableStyle )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -400,11 +400,11 @@
|
|||||||
if ($RangeName) { Add-ExcelName -Range $ws.Cells[$dataRange] -RangeName $RangeName}
|
if ($RangeName) { Add-ExcelName -Range $ws.Cells[$dataRange] -RangeName $RangeName}
|
||||||
|
|
||||||
#Allow table to be inserted by specifying Name, or Style or both; only process autoFilter if there is no table (they clash).
|
#Allow table to be inserted by specifying Name, or Style or both; only process autoFilter if there is no table (they clash).
|
||||||
if ($null -ne $TableName) {
|
if ($null -ne $TableName -or $PSBoundParameters.ContainsKey('TableStyle')) {
|
||||||
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName $PSBoundParameters['TableName'] -TableStyle $TableStyle
|
#Already inserted Excel table if input was a DataTable
|
||||||
|
if ($InputObject -isnot [System.Data.DataTable]) {
|
||||||
|
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName $TableName -TableStyle $TableStyle
|
||||||
}
|
}
|
||||||
elseif ($PSBoundParameters.ContainsKey('TableStyle')) {
|
|
||||||
Add-ExcelTable -Range $ws.Cells[$dataRange] -TableName "" -TableStyle $TableStyle
|
|
||||||
}
|
}
|
||||||
elseif ($AutoFilter) {
|
elseif ($AutoFilter) {
|
||||||
try {
|
try {
|
||||||
@@ -413,7 +413,6 @@
|
|||||||
}
|
}
|
||||||
catch {Write-Warning -Message "Failed adding autofilter to worksheet '$WorksheetName': $_"}
|
catch {Write-Warning -Message "Failed adding autofilter to worksheet '$WorksheetName': $_"}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PivotTableDefinition) {
|
if ($PivotTableDefinition) {
|
||||||
foreach ($item in $PivotTableDefinition.GetEnumerator()) {
|
foreach ($item in $PivotTableDefinition.GetEnumerator()) {
|
||||||
$params = $item.value
|
$params = $item.value
|
||||||
|
|||||||
Reference in New Issue
Block a user