From cc7d18cc593cca06638c54ad06729214bc598278 Mon Sep 17 00:00:00 2001 From: ili101 Date: Mon, 18 Nov 2019 12:21:21 +0200 Subject: [PATCH] EPPlus empty row on an empty table --- Export-Excel.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index c0a97f2..3735b5f 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -631,6 +631,10 @@ } if ($null -ne $TableName -or $PSBoundParameters.ContainsKey("TableStyle")) { $null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader),$TableStyle ) + # Workaround for EPPlus not marking the empty row on an empty table as dummy row. + if ($InputObject.Rows.Count -eq 0) { + ($ws.Tables | Select-Object -Last 1).TableXml.table.SetAttribute('insertRow', 1) + } } else { $null = $ws.Cells[$row,$StartColumn].LoadFromDataTable($InputObject, (-not $noHeader) )