mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Export-Excel.ps1
532: Now mode TableName is auto generated if not specified (shouldn't matter just in case). 632: Fix -DataTable "" to use LoadFromDataTable with style (auto generated name) 820: DataTable + TableStyle without TableName corruption fix. Also simplified even more. 822: Change back to "-TableName $TableName" as cange broke test: Export-Excel.Tests.ps1 617: Undo change test was correct.
This commit is contained in:
@@ -529,7 +529,7 @@
|
|||||||
if (-not $PSBoundParameters.ContainsKey("TableName") -and
|
if (-not $PSBoundParameters.ContainsKey("TableName") -and
|
||||||
-not $PSBoundParameters.ContainsKey("TableStyle") -and
|
-not $PSBoundParameters.ContainsKey("TableStyle") -and
|
||||||
-not $AutoFilter) {
|
-not $AutoFilter) {
|
||||||
$TableName = 'Table1'
|
$TableName = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($ExcelPackage) {
|
if ($ExcelPackage) {
|
||||||
@@ -629,8 +629,7 @@
|
|||||||
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")) {
|
if ($null -ne $TableName -or $PSBoundParameters.ContainsKey("TableStyle")) {
|
||||||
$TableName = $null
|
|
||||||
$null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader),$TableStyle )
|
$null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader),$TableStyle )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -818,11 +817,10 @@
|
|||||||
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
|
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 {
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ Describe ExportExcel {
|
|||||||
$dataWs = $Excel.Workbook.Worksheets["NoOffset"]
|
$dataWs = $Excel.Workbook.Worksheets["NoOffset"]
|
||||||
|
|
||||||
it "Created a new sheet and auto-extended a table and explicitly extended named ranges " {
|
it "Created a new sheet and auto-extended a table and explicitly extended named ranges " {
|
||||||
$dataWs.Tables["ProcTab"].Address.Address | Should be "A1:E11"
|
$dataWs.Tables["ProcTab"].Address.Address | Should be "A1:E21"
|
||||||
$dataWs.Names["CPU"].Rows | Should be 20
|
$dataWs.Names["CPU"].Rows | Should be 20
|
||||||
$dataWs.Names["CPU"].Columns | Should be 1
|
$dataWs.Names["CPU"].Columns | Should be 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user