Closed chuckchamberland closed 3 years ago
Close-ExcelPackage
has a -Password
parameter, but that is for the book. Sanity check would be to see if that fails too.
Sorry, I've never tried the $sheet.Protection.IsProtected
or $sheet.Protection.SetPassword("test")
, the are part of the 3rd party DLL I use in the module (called EPPlus) that saves the file and gives access to those properties. Could be an error in there, or it could be OneDrive.
Tangential question: How do you enable protection without setting the password?
Running Close-ExcelPackage $xls -Password "test2"
also does not work with C:\User\Username\Desktop, but does with the redirected path.
My guess is it's an issue with the way that EPPlus handles saving the package. What version is used in ImportExcel?
EPPLus v 4.5.3
Have not played with the protection aspects of the library.
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.
When trying to apply worksheet protection to a spreadsheet, protection will fail to be enabled if the target file resides in a redirected known folder (such as the Desktop). This is a common scenario now that the OneDrive desktop client can enable known folder redirection without any additional configuration. Example below:
This is a silent failure, so I can't determine at what point access to the file is failing. Running this script line-by-line shows that the excel package appears to be correctly retrieved (
$xls
). Therefore I suspect a problem with either$sheet.Protection
orClose-Excel
.