简体   繁体   English

使用ClosedXML加密Excel文件

[英]Encrypt excel file using ClosedXML

We are using ClosedXML library to generate our excel reports. 我们正在使用ClosedXML库来生成我们的Excel报告。 A new requirement form client is to password protect reports marked as confidential. 客户端的一项新要求是使用密码保护标记为机密的报告。 There is a method XLWorkbook.Protect() with some overloads, however, none of it is encrypting a file, just locking structure at best. 有一个带有一些重载的XLWorkbook.Protect()方法,但是,它没有一个在加密文件,最多只是锁定结构。 In other words, you can still see data after opening a file, MS Excel will not ask you for a password. 换句话说,打开文件后您仍然可以看到数据,MS Excel不会要求您输入密码。

  1. Is ClosedXML even supporting excel file encryption? ClosedXML甚至支持excel文件加密吗? On their wiki which I found on GitHub, there is the only article about protecting sheets and even for formatting and structure. 在我在GitHub上找到的他们的Wiki上,只有关于保护工作表,甚至用于格式和结构的文章。
  2. Was anyone able to find a way with ClosedXML? 有谁能够找到ClosedXML的方法吗? We would like to avoid using another library (like Spire.XSL; Microsoft.Office.Interop.Excel is not an option) if possible. 如果可能的话,我们希望避免使用其他库(例如Spire.XSL;不是Microsoft.Office.Interop.Excel)。

Thanks 谢谢

After some try/fails and code disassembling I realized that ClosedXML is not supporting encryption at all; 经过几次尝试/失败和代码分解后,我意识到ClosedXML根本不支持加密;它只支持加密。 at least I was unable to find trace of it. 至少我找不到它的踪迹。 Maybe they will add it later. 也许他们稍后会添加。 We were able to convince client to give us a time to refactor the code and we are using EPPlus now. 我们能够说服客户给我们一些时间来重构代码,我们现在正在使用EPPlus。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM