IronXL How-Tos Set Password to Worksheet How to Set Password to Worksheet Chaknith Bin Updated:June 22, 2025 Restricting a worksheet with a Read-Only authentication is a very common requirement for data files. IronXL makes it easy to apply Read-Only protection to worksheets in .NET. How to Password Protect Worksheets Download the C# library to password protect worksheets Access the password-protected worksheet in the opened workbook Apply password protection to the selected worksheet Remove password protection from the selected worksheet Export the spreadsheet to different spreadsheet formats Get started with IronXL Start using IronXL in your project today with a free trial. First Step: Start for Free Access a Password Protected Worksheet IronXL allows you to access and modify any protected worksheet without requiring the password. Once the spreadsheet is opened with IronXL, you can modify any cell in any worksheet. Apply Password to Worksheet To restrict modifications to a worksheet while allowing users to view its content in Excel, use the ProtectSheet method with a password as a parameter. For example, workSheet.ProtectSheet("IronXL"). This sets a password-based ReadOnly authentication for the selected worksheet. :path=/static-assets/excel/content-code-examples/how-to/set-password-worksheet-protect.cs using IronXL; WorkBook workBook = WorkBook.Load("sample.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; // Set protection for selected worksheet workSheet.ProtectSheet("IronXL"); workBook.Save(); Imports IronXL Private workBook As WorkBook = WorkBook.Load("sample.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Set protection for selected worksheet workSheet.ProtectSheet("IronXL") workBook.Save() $vbLabelText $csharpLabel Open a Password-Protected Worksheet Remove Password from Worksheet To remove a password from a specific worksheet, you can use the UnprotectSheet method. Simply call workSheet.UnprotectSheet() to remove any password associated with the worksheet. :path=/static-assets/excel/content-code-examples/how-to/set-password-worksheet-unprotect.cs // Remove protection for selected worksheet. It works without password! workSheet.UnprotectSheet(); ' Remove protection for selected worksheet. It works without password! workSheet.UnprotectSheet() $vbLabelText $csharpLabel IronXL allows you to protect and unprotect any Excel workbook and worksheet with a single line of C# code. Frequently Asked Questions How can I password protect an Excel worksheet in C#? You can use IronXL's ProtectSheet method to set a password for an Excel worksheet in C#. Simply pass a password as a parameter to the method, for example, workSheet.ProtectSheet("IronXL"). Is it possible to access and modify a password-protected worksheet in C# without the password? Yes, with IronXL, you can access and modify a password-protected worksheet without needing the password, once the spreadsheet is opened. How can I remove a password from an Excel worksheet using C#? To remove a password from an Excel worksheet, use IronXL's UnprotectSheet method. Call workSheet.UnprotectSheet() to clear any password associated with the worksheet. What steps are involved in applying password protection to a worksheet in C#? First, download the IronXL C# library from NuGet. Then, use the ProtectSheet method to apply password protection to a selected worksheet in an opened workbook. How can I export a password-protected worksheet to different formats in C#? IronXL allows you to export a password-protected worksheet to various formats. After applying protection, you can use the SaveAs method to export your spreadsheet to different formats. What is the benefit of using read-only authentication for worksheets in C#? Using read-only authentication with IronXL enables you to restrict modifications while allowing users to view the worksheet content. This is achieved by using the ProtectSheet method with a password. How do I begin using IronXL for worksheet protection in C#? To start using IronXL for worksheet protection, you need to download and reference the IronXL library in your C# project from NuGet. Can I protect and unprotect an Excel workbook using a single line of C# code? Yes, IronXL allows you to protect and unprotect any Excel workbook or worksheet with a single line of C# code, making it an efficient tool for managing worksheet security. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Free NuGet Download Total downloads: 1,552,917 View Licenses