1

We are using ClosedXML library to generate our excel reports. 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. In other words, you can still see data after opening a file, MS Excel will not ask you for a password.

  1. Is ClosedXML even supporting excel file encryption? On their wiki which I found on GitHub, there is the only article about protecting sheets and even for formatting and structure.
  2. Was anyone able to find a way with ClosedXML? We would like to avoid using another library (like Spire.XSL; Microsoft.Office.Interop.Excel is not an option) if possible.

Thanks

Diomos
  • 420
  • 5
  • 15
  • Given how many duplicate questions there are about this, what did you try? Where is the code? Have you checked the [example](https://github.com/ClosedXML/ClosedXML/wiki/Sheet-Protection) on the library's repo? Don't force people to guess – Panagiotis Kanavos Jul 13 '18 at 13:35
  • BTW Epplus is far more popular and [supports encryption](https://github.com/JanKallman/EPPlus/blob/master/SampleApp/Sample10.cs) – Panagiotis Kanavos Jul 13 '18 at 13:41
  • @PanagiotisKanavos No, my question is not a duplicate. And yes, I went through their wiki on GitHub and tried their code and it didn't work. It will just a spreadsheets protection: e.g. to not allow you add more columns or change data but will not encrypt excel file itself. All of this is clear when reading my question. And as for the code IMO I don't see any reason to paste code when I am sure it was not error in my code. My question was specific towards functionality, not about exceptions or not working code. Or did I miss something? – Diomos Jul 17 '18 at 10:28
  • Yes, you do need to post your code, even when you think the problem isn't in in it. If you want *an answer* you should make it as easy as possible for people to investigate and answer. Otherwise people won't even be able to reproduce the problem, much less suggest an answer – Panagiotis Kanavos Jul 17 '18 at 11:29
  • @PanagiotisKanavos OK, thanks for suggestion. – Diomos Jul 17 '18 at 11:56

1 Answers1

1

After some try/fails and code disassembling I realized that ClosedXML is not supporting encryption at all; 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.

Diomos
  • 420
  • 5
  • 15