Kryptera och dekryptera ODS-filer

Kryptera med OpenOffice Calc

  1. VäljSpara som och klicka påSpara med lösenord låda.
  2. Klicka påSpara knapp.
  3. Skriv ditt önskade lösenord i bådeAnge lösenord för att öppna ochBekräfta lösenord fälten i fönstret Ange lösenord som öppnas.
  4. Klicka påOK knappen för att spara filen.

Kryptera ODS-filen med Aspose.Cells för .Net

För att kryptera en ODS-fil, ladda filen och ställ inArbetsbok Inställningar. Lösenord värde till det faktiska lösenordet innan du sparar det. Den utdatakrypterade ODS-filen kan endast öppnas i OpenOffice.

// 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");

Dekryptera ODS-fil med Aspose.Cells för .Net

För att dekryptera en ODS-fil, ladda filen genom att ange ett lösenord iLoadOptions.Password . När filen är laddad, ställ inArbetsbok Inställningar. Lösenord sträng till 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");