使用密码

时间:2018-05-15 09:17:16

标签: excel aspose

我正在使用Apose.cells API创建Excel文件:

book.SetEncryptionOptions(EncryptionType.XOR, 40);
book.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);
book.Settings.Password = "test;

当我尝试打开生成的excel文件时,会提示输入密码,在输入正确的密码后,文件会打开,并显示以下错误消息

"Excel found unreadable content". Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes

<info>Excel recovered your formulas and cell values, but some data may have been lost.</info>

1 个答案:

答案 0 :(得分:0)

此问题似乎特定于您的Excel文件。请提供您的Excel文件进​​行测试。

我们使用most recent version i.e. 18.4.6测试了这个问题,它运行正常。请参阅以下代码。它会加载具有Book1.xls,并在执行代码后将其保存为output.xls,在Microsoft Excel中可以正常打开,而不会出现任何错误。

下载链接:

<强> C#

Workbook book = new Workbook("Book1.xls");
book.SetEncryptionOptions(EncryptionType.XOR, 40);
book.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);
book.Settings.Password = "test123";
book.Save("output.xls");

注意: 我在Aspose担任开发人员传播者