Export-Excel with -Password failed with error
When I tried to create Excel file using Export-Excel with -Password "Test1234!", there was an error message as below. catch { throw "Could not open Excel Package $path" }
Need help on how to set this -Password parameter. Module version is 7.8.4
Removing the -Password parameter was able to create the file successfully without any password.
Please post the versions are running and the environment.
How do I check the ABE? I am running Windows 10.
I tried with this example (running PowerShell 7 as administrator)
PS C:\Users\lcp> $data | Export-Excel .\salesData.xlsx -Password 'test' Exception: C:\Users\lcp\Documents\PowerShell\Modules\ImportExcel\7.8.4\Public\Export-Excel.ps1:126 Line | 126 | catch { throw "Could not open Excel Package $path" } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Could not open Excel Package .\salesData.xlsx
what is in $data?
PS C:\Users\lcp> $data
Region State Units Price
West Texas 927 923.71 North Tennessee 466 770.67 East Florida 520 458.68 East Maine 828 661.24 West Virginia 465 053.58 North Missouri 436 235.67 South Kansas 214 992.47 North North Dakota 789 640.72 South Delaware 712 508.55
Here is another info.
PS C:\Users\lcp> $data | Export-Excel .\salesData.xlsx -Password 'test' MethodInvocationException: C:\Users\lcp\Documents\PowerShell\Modules\ImportExcel\7.8.4\Public\Export-Excel.ps1:679 Line | 679 | if ($Password) { $pkg.Save($Password) } | ~~~~~~~~~~~~~~~~~~~~ | Exception calling "Save" with "1" argument(s): "Error saving file C:\Users\lcp\salesData.xlsx"
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@dfinke Any update on this fix. I tried again with the following command, and encountered the same error.
Get-Process | Export-Excel -Path C:\Temp\Processes.xlsx -Password "abc"
MethodInvocationException: C:\Users\lcp\Documents\PowerShell\Modules\ImportExcel\7.8.4\Public\Export-Excel.ps1:679 Line | 679 | if ($Password) { $pkg.Save($Password) } | ~~~~~~~~~~~~~~~~~~~~ | Exception calling "Save" with "1" argument(s): "Error saving file C:\Temp\Processes.xlsx"
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.