简体   繁体   中英

How to create a password protected Excel file?

I have a list type of object and i need to create a excel file which should required password to open that excel file in ASP.NET C#.

I have tried ClosedXML package but that is not working well. And also I have tried much more example but I didn't found any good example.

Please, If any one have done these type of example then please let me know.

Much Appreciation !

If you want an Excel password all you need is something like this:

using Microsoft.Office.Interop.Excel

//create your spreadsheet here...

WorkbookObject.Password = password;
WorkbookObject.SaveAs("spreadsheet.xls")

This requires Excel to be installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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