HTML
JPG
PDF
XML
ODS
ODS
Encrypt ODS Files via C#
Password-protect Excel spreadsheets including ODS format using .NET Library.
How to Protect ODS File Using C#
In order to protect ODS 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.
Aspose.Cells
PM> Install-Package Aspose.Cells
Protect ODS via C#
You need
referenced in your project to execute the following workflow.
- Instantiate Workbook class with path to ODS file
- Get the default or any Worksheet to add protection
- Protect Worksheet with Worksheet.Protect method
- Protect Workbook with Workbook.Protect method
- Save result in ODS format
System Requirements
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
Command
// load the ODS Excel file
var book = new Aspose.Cells.Workbook("unlocked.ods");
// access the first worksheet
var worksheet = book.Worksheets[0];
// protect the worksheet with password
worksheet.Protect(Aspose.Cells.ProtectionType.All, "password", null);
// protect the whole workbook with password
book.Protect(Aspose.Cells.ProtectionType.All, "password");
// save the modified file in default format
book.Save("protected.ods");