From bd7d70a050916b8bebbee613d38ad08fdca6125e Mon Sep 17 00:00:00 2001 From: dfinke Date: Mon, 31 Dec 2018 18:45:16 -0500 Subject: [PATCH] Fix when only one property name is in the incoming data --- Export-Excel.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index 6b239ae..7876fac 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -810,7 +810,7 @@ # if we have 5 columns from 3 to 8, headers are numbered 0..4, so that is in the for loop and used for getting the name... # but we have to add the start column on when referencing positions foreach ($c in 0..($LastCol - $StartColumn)) { - $targetRangeName = $script:Header[$c] #Let Add-ExcelName fix (and warn about) bad names + $targetRangeName = @($script:Header)[$c] #Let Add-ExcelName fix (and warn about) bad names Add-ExcelName -RangeName $targetRangeName -Range $ws.Cells[$targetRow, ($StartColumn + $c ), $LastRow, ($StartColumn + $c )] try {#this test can throw with some names, surpress any error if ([OfficeOpenXml.FormulaParsing.ExcelUtilities.ExcelAddressUtil]::IsValidAddress(($targetRangeName -replace '\W' , '_' ))) {