Unlock XLSX Spreadsheet via C#
Remove protection from XLSX using .NET library.
How to Unlock XLSX File Using C#
In order to remove protection XLSX file, we’ll use
API which is a feature-rich, powerful and easy to use document protection API for C# platform. Open
package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.
PM> Install-Package Aspose.Cells
Unlock XLSX via C#
referenced in your project to execute the following workflow.
- Instantiate Workbook class with path to protected XLSX file
- Get the default or any Worksheet to remove protection
- Remove Worksheet protection with Worksheet.Unprotect method
- Remove Workbook protection with Workbook.Unprotect method
- Save result in XLSX format
Aspose.Cells for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono or Xamarin Platforms
- Development environment like Microsoft Visual Studio
- Add reference to the Aspose.Cells for .NET DLL in your project
// instantiate a Workbook object with protected XLSX file var workbook = new Aspose.Cells.Workbook("protected.xlsx"); // access the default worksheet in the Excel file var worksheet = workbook.Worksheets; // unprotect worksheet without a password worksheet.Unprotect(); // unprotect workbook with password workbook.Unprotect("password"); // save the result back in XLSX format workbook.Save("unprotected.xlsx", Aspose.Cells.SaveFormat.Auto);