-
Notifications
You must be signed in to change notification settings - Fork 421
Closed
Labels
Description
This code appears to work for me (assuming a plain text [string] parameter added to the Import-Excel function).
if($Password)
{
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage
try
{
$xl.Load($Stream,$Password)
}
catch
{
$stream.Close()
$stream.Dispose()
$xl.Dispose()
$xl = $null
throw $_
}
}
else
{
$xl = New-Object -TypeName OfficeOpenXml.ExcelPackage -ArgumentList $stream
}
In the event that a bad password is specified, we get the error: Exception calling "Load" with "2" argument(s): "Invalid password".
Note: This is not the same as a password "protected" workbook or worksheet.