是否可以在 C# MVC3 项目中添加对 Microsoft Office DLL 的引用?
我不知道这是否可行,但我想在我的 MVC3 项目中添加对 MS Office 的程序引用。
更具体地说,我希望能够使用内置 Office 对象以编程方式创建编辑和发送动态生成的 Office 文档。与使用第三方 FOSS API 相比,我更喜欢使用对象的直接 MS 版本,因为我有很多 VBA 知识,并且认为直接使用 MS-Office“胆量”将是一个对我来说容易多了。
假设 Office 已正确安装在运行它的服务器上,我应该能够直接从 C# MVC 中引用 Office 应用程序并编写脚本,对吗?
我想我可能正在寻找 3 个东西:
- C# 的
using Microsoft.Office;
指令 - 我必须注册的 DLL 的名称
regsvr32
/ .dll - 我在 Visual Studio 中添加对 MVC3 项目的引用的方式
除非我还缺少任何其他内容,否则我希望从那里我能够创建一个新的 Excel 对象并拥有网络服务器构建它。
Excel objXL = new Microsoft.Office.Excel();
objXL.<do stuff>;
objXL.Save(<bla bla bla>);
' profit!
谢谢
I don't know if this is possible, but I'd like to add a program reference to MS office in my MVC3 project.
More specifically, I'd like to be able to programmatically create edit and send dynamically generated office documents using the built-in Office objects. As compared to using a third party FOSS API, I'd prefer to use the direct MS version of the objects because I've got a lot of VBA know how and think that working directly with the MS-Office "guts" will be a lot easier for me.
Assuming office is properly installed on the server this runs on, I should be able to reference and script the Office application directly from within a C# MVC right?
I figure I'm probably looking for 3 things
- the
using Microsoft.Office;
directive for C# - the name of the DLL that I must register
regsvr32 <pathname>/<officeDLLname>.dll
- the way I go about adding the reference to my MVC3 project in visual studio
Unless there is anything else I'm missing, I'd expect that from there I'd be able to create a new Excel object and have the web server build it.
Excel objXL = new Microsoft.Office.Excel();
objXL.<do stuff>;
objXL.Save(<bla bla bla>);
' profit!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要授予 aspnet/网络身份用户添加/编辑文档的权限。除此之外,为什么不呢?
you will need to give aspnet/network identity user a permissions to add/edit documents. other than that, why not?