加密和解密 ODS 个文件

使用 OpenOffice Calc 加密

  1. 选择另存为并点击用密码保存盒子。
  2. 点击救球按钮。
  3. 在两者中输入您想要的密码输入密码打开确认密码打开的“设置密码”窗口中的字段。
  4. 点击好的按钮保存文件。

使用 .Net 的 Aspose.Cells 加密 ODS 文件

要加密 ODS 文件,加载文件并设置工作簿设置.密码在保存之前将值设置为实际密码。输出的加密文件ODS只能在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");

使用 .Net 的 Aspose.Cells 解密 ODS 文件

要解密 ODS 文件,请通过在加载选项.密码.加载文件后,设置工作簿设置.密码字符串为空。

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