The Syncfusion® .NET Excel Library (XlsIO) allows users to protect and unprotect Excel files in C# and VB.NET with various customization options. This prevents unnecessary data loss or modifications to Excel worksheets while making them available to others with limited access.
This example code shows how to encrypt an Excel workbook with a password using the Syncfusion® .NET Excel Library with just a few lines of C# code.
// Initialize Excel engine and application
using ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
// Create a workbook and worksheet
IWorkbook workbook = application.Workbooks.Create(1);
// Encrypt the workbook with a password
workbook.PasswordToOpen = "syncfusion";
// Save the Excel document
using FileStream stream = new FileStream("EncryptedWorkbook.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(stream);
Discover how the Security features in the Syncfusion® Excel Library enhance data protection by providing robust mechanisms to safeguard Excel files from unauthorized access.
Add password protection to an Excel workbook to restrict access, ensuring that only authorized users can open and modify its contents.
Remove password protection from an Excel workbook, allowing access to its contents for editing and viewing without restrictions.
Secure the workbook with a password, preventing unauthorized changes to its structure.
Lock a worksheet with a password, preventing unauthorized edits to its content while allowing specific actions based on permissions.
Remove protection from a worksheet, granting full access to all content for editing or formatting purposes.
Lock specific cells within a worksheet, restricting edits to ensure data integrity while allowing modifications to other cells.
Discover valuable resources from our knowledge base articles to enhance your efficiency in using security.
Knowledge base
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Product Updates
Technical Support
Yes. You can remove a password from an Excel document by changing the password value to empty using the Syncfusion® .NET Excel library.
You can use Workbook protection, which uses the Syncfusion® Excel library to prevent adding or removing worksheets in the Excel document.
You can use the encryption feature from the Syncfusion® Excel library to set a password for the Excel document. This will ensure that only specific users with passwords can read the content.
You can open an Excel document in read-only mode by setting the ReadOnlyRecommended value to true using the Syncfusion® Excel library.
No. You can provide any combination of passwords for Excel documents.
No. It is not possible to open encrypted Excel documents without a password.
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.