How to Set a Password to Workbook
Ensuring that information or data is shared with the correct individual is crucial for maintaining proper authority. With IronXL, you can create password-protected spreadsheets and secure each individual worksheet.
How to Set a Password to Workbook
- Download the C# library for password-protecting workbooks
- Access the password-protected workbook
- Apply password protection to the workbook
- Remove password protection from the workbook
- Export the encrypted workbook
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Install with NuGet
Install-Package IronXL.Excel
Download DLL
Manually install into your project
Start using IronPDF in your project today with a free trial.
Check out IronXL on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming Excel with C#.
Install-Package IronXL.Excel
Consider installing the IronXL DLL directly. Download and manually install it for your project or GAC form: IronXL.zip
Manually install into your project
Download DLLAccess a Password-Protected Workbook
A protected spreadsheet can be opened by providing the password as the second parameter to the Load method. For example: WorkBook.Load("sample.xlsx", "IronSoftware")
.
Please note
Apply a Password to Workbook
To password-protect a spreadsheet, use the Encrypt
method.
:path=/static-assets/excel/content-code-examples/how-to/set-password-workbook-protect.cs
WorkBook workBook = WorkBook.Load("sample.xlsx");
// Open protected spreadsheet file
WorkBook protectedWorkBook = WorkBook.Load("sample.xlsx", "IronSoftware");
// Set protection for spreadsheet file
workBook.Encrypt("IronSoftware");
workBook.Save();
Dim workBook As WorkBook = WorkBook.Load("sample.xlsx")
' Open protected spreadsheet file
Dim protectedWorkBook As WorkBook = WorkBook.Load("sample.xlsx", "IronSoftware")
' Set protection for spreadsheet file
workBook.Encrypt("IronSoftware")
workBook.Save()
Open a Password-Protected Workbook
Remove Password from Workbook
To remove the password from a spreadsheet, simply set the Password field to null, as demonstrated in the code below:
Please note
:path=/static-assets/excel/content-code-examples/how-to/set-password-workbook-unprotect.cs
// Remove protection for opened workbook. Original password is required.
workBook.Password = null;
' Remove protection for opened workbook. Original password is required.
workBook.Password = Nothing
IronXL provides the ability to protect and unprotect Excel workBooks and workSheets with a single line of C# code.