Created
December 15, 2020 01:42
-
-
Save aspose-com-gists/8d4da2809d6fd2a87f994b2890a21d98 to your computer and use it in GitHub Desktop.
Protect Excel Files in 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
// Open the Excel file | |
Workbook workbook = new Workbook("Excel.xlsx"); | |
// Protect workbook by specifying protection type | |
workbook.Protect(ProtectionType.All, "12345"); | |
// Save the file | |
workbook.Save("Excel.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
// Open the Excel file | |
Workbook workbook = new Workbook("Excel.xlsx"); | |
// Unprotect workbook | |
workbook.Unprotect("12345"); | |
// Set password to null | |
workbook.Settings.Password = null; | |
// Save the file | |
workbook.Save("Excel.xlsx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment