diff --git a/PSExcel/Import-XLSX.ps1 b/PSExcel/Import-XLSX.ps1 index 5c8bd4f..55897f3 100644 --- a/PSExcel/Import-XLSX.ps1 +++ b/PSExcel/Import-XLSX.ps1 @@ -128,6 +128,12 @@ else { $worksheet = $workbook.Worksheets[$Sheet] + if(!$worksheet) + { + Write-Error "Unkown worksheet and/or Failed to gather Worksheet '$Sheet' data for file '$file':`n$_" + continue + } + $dimension = $worksheet.Dimension $Rows = $dimension.Rows