简体   繁体   English

如何创建受密码保护的 Excel 文件?

[英]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#.我有一个列表类型的对象,我需要创建一个 excel 文件,它应该需要密码才能在 ASP.NET C# 中打开该 excel 文件。

I have tried ClosedXML package but that is not working well.我尝试过 ClosedXML 包,但效果不佳。 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:如果你想要一个 Excel 密码,你只需要像这样:

using Microsoft.Office.Interop.Excel

//create your spreadsheet here...

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

This requires Excel to be installed.这需要安装 Excel。

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

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