From b50cc67bb370fefbb870f742b3bf0fa6a74d6743 Mon Sep 17 00:00:00 2001 From: jhoneill Date: Thu, 2 Aug 2018 13:56:01 +0100 Subject: [PATCH] warn instead of aborting when a property won't go into a cell. --- Export-Excel.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index 32a1f0d..beaebb5 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -635,7 +635,8 @@ if ($isDataTypeValueType) { $ColumnIndex = $StartColumn $Row += 1 - Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData + try {Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData} + catch {Write-Warning "Could not insert value at Row $Row. "} } else { #region Add headers @@ -667,8 +668,8 @@ foreach ($Name in $script:Header) { #region Add non header values - Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData.$Name - + try {Add-CellValue -TargetCell $ws.Cells[$Row, $ColumnIndex] -CellValue $TargetData.$Name} + catch {Write-Warning -Message "Could not insert the $Name property at Row $Row, Column $Column"} $ColumnIndex += 1 #endregion }