Create password protected excel file using Closedxml library
I am new to c # asp.net and I tried to create XLS file using 3rd party library "Closedxml". Now I also want to password protect the XLS file, how can I achieve this.
Your help will be seen. thanks in advance Ashish
+3
Ashish singla
source
to share
2 answers
Had the same problem - needed to test the excel file without using interop libraries.
With ClosedXML you can password protect at the worksheet level:
var ws = wb.Worksheets.Add("someworksheet");
ws.Protect("123"); // 123 will be the password
And it looks like you can lock the structure of the workbook (prevent the worksheet from filling in by adding / removing / renaming) without the option to set a password, although they haven't tested this bit:
var wb = new XLWorkbook();
wb.Protect(bool LockStrucure, bool LockWindows);
links: sheet protection example
+4
JesseZ
source
to share
To protect a file with a password in ClosedXML is not possible see Github
0
Cerveser
source
to share