Encrypt And Decrypt ODS files
Encrypt with OpenOffice Calc
- Select Save as and Click the Save With Password box.
- Click the Save button.
- Type your desired password into both the Enter Password to Open and Confirm Password fields in the Set Password window that opens.
- Click the OK button to save the file.
Encrypt ODS file with Aspose.Cells for .Net
For encrypting an ODS file, load the file and set the WorkbookSettings.Password value to the actual password before saving it. The output encrypted ODS file can be opened in OpenOffice only.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Open an ODS file | |
Workbook workbook = new Workbook(sourceDir + "sampleODSFile.ods"); | |
// Password protect the file | |
workbook.Settings.Password = "1234"; | |
// Save the ODS file | |
workbook.Save(outputDir + "outputEncryptedODSFile.ods"); |
Decrypt ODS file with Aspose.Cells for .Net
For decrypting an ODS file, load the file by providing a password in the LoadOptions.Password. Once the file is loaded, set the WorkbookSettings.Password string to null.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Open an encrypted ODS file | |
Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.Ods); | |
// Set original password | |
loadOptions.Password = "1234"; | |
// Load the encrypted ODS file with the appropriate load options | |
Workbook workbook = new Workbook(sourceDir + "sampleEncryptedODSFile.ods", loadOptions); | |
// Set the password to null | |
workbook.Settings.Password = null; | |
// Save the decrypted ODS file | |
workbook.Save(outputDir + "outputDecryptedODSFile.ods"); |