C#:如何打开和关闭 Excel 工作簿?
有人知道如何简单地打开和关闭 Excel 工作簿吗?
我不需要从文件中读取任何数据,我只需要打开和关闭它。 (*)
我猜我需要引用 Microsoft.Office.Interop.Excel 程序集。
*原因:我已经使用第三方库(Aspose)配置了数据透视表信息。现在我需要读取生成的数据透视表。
不幸的是,Aspose 库无法在运行时生成数据透视表。它需要有人使用 Excel 打开文件以便 Excel 可以生成数据透视表值。
Does anyone know how to simply open and close an Excel workbook?
I don't need to read any data from the file, I just need to open and close it. (*)
I'm guessing that I'll need to reference the Microsoft.Office.Interop.Excel assembly.
*Reason: I've already configured pivot table information with a 3rd party library (Aspose). Now I need to read the generated pivot table.
Unfortunately, the Aspose library can't generate the pivot table at runtime. It needs someone to open the file with Excel so that Excel can generate the pivot table values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
引用 Microsoft.Office.Interop.Excel 后还要确保在最后进行清理。
after referencing Microsoft.Office.Interop.Excel also Make sure to clean up in the finally.
快速谷歌给了我这个代码项目:
http://www.codeproject.com/知识库/office/csharp_excel.aspx
A quick Google gives me this on code project:
http://www.codeproject.com/KB/office/csharp_excel.aspx
考虑使用 System.Diagnostics.Process 来启动、监视和关闭 Excel。该网站提供了很好的介绍: http://www.thescarms.com/dotnet/Process.aspx ,包括使用不可见窗口运行并向其发送输入。
Consider using System.Diagnostics.Process to start, monitor, and close Excel. This site gives a good intro: http://www.thescarms.com/dotnet/Process.aspx, including running with an invisible window and sending input to it.