Related Article(s):
Last active
August 10, 2023 08:10
-
-
Save GroupDocsGists/40ad04acb96b13a60fa2c002c61f1fbc to your computer and use it in GitHub Desktop.
Protection of Excel Spreadsheets by Adding, Removing, and Changing Password using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Change password of protected Excel spreadsheets using C# | |
*/ | |
string filePath = @"path/protected-spreadsheet.xlsx"; | |
LoadOptions loadOptions = new LoadOptions("mySECRETpassWORD"); | |
UpdatePasswordOptions updateOptions = new UpdatePasswordOptions("TOPSECRET_pa22WORD"); | |
using (Merger merger = new Merger(filePath, loadOptions)) | |
{ | |
merger.UpdatePassword(updateOptions); | |
merger.Save(@"path/pwd-changed-spreadsheet.xlsx"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Add password protection to Excel spreadsheets files (XLS/XLSX) using C# | |
*/ | |
string filePath = @"path/spreadsheet.xlsx"; | |
AddPasswordOptions addOptions = new AddPasswordOptions("mySECRETpassWORD"); | |
using (Merger merger = new Merger(filePath)) | |
{ | |
merger.AddPassword(addOptions); | |
merger.Save(@"path/protected-spreadsheet.xlsx"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Remove password protection from Excel spreadsheets using C# | |
*/ | |
string filePath = @"path/protected-spreadsheet.xlsx"; | |
LoadOptions loadOptions = new LoadOptions("mySECRETpassWORD"); | |
using (Merger merger = new Merger(filePath, loadOptions)) | |
{ | |
merger.RemovePassword(); | |
merger.Save(@"path/unlocked-spreadsheet.xlsx"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment