本文介绍了密码保护 C# 中的 Excel 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Does anyone know the syntax for this? I've been looking everywhere and all I can find is C++ code for this. I'm trying to password protect an excel file programatically using the System.IO.Packaging namespace.
Any ideas?
Additional notes:
I'm NOT using the Excel interop--but instead the System.IO.Packaging namespace to encrypt and password protect the excel file.
解决方案
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.
That's nothing to do with System.IO.Packaging
of course, so you might need to restate your question...
这篇关于密码保护 C# 中的 Excel 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!