C#WebBrowser和Excel实例 [英] C# WebBrowser and Excel instance
本文介绍了C#WebBrowser和Excel实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我使用WebBrowser控件打开Excel文件。
问题如果之前已经有一个打开的Excel,WebBrowser使用相同的Excel(应用程序)实例。
是否有一种方法来指示WebBrowser应该创建一个新的Excel实例?
或者是否可以强制(或阻止)在特定实例中打开新的Excel文件?
谢谢
Hello,
I use a WebBrowser control to open an Excel file.
The problem is that if there is already an open Excel before, the WebBrowser uses the same instance of Excel (Application).
Is there a method to indicate that the WebBrowser should create a new instance of Excel?
Or is it possible to force (or prevent) new Excel files to open in a specific instance?
thank you
推荐答案
如果我理解你的话......
MS Excel是单实例应用程序,这意味着Excel将在同一实例中打开下一个文件。要使用Interop强制创建另一个实例,您需要使用new
关键字打开它。
If i understand you well...
MS Excel is a single-instance application, which means that Excel will open next file in the same instance. To force creating another instance, using Interop, you need to open it usingnew
keyword.
Excel.Application oExcFirstInstance = new Excel.Application();
Excel.Application oExcSecondInstance = new Excel.Application();
oExcFirstInstance.Workbooks.Open(...);
oExcFirstInstance.Workbooks.Open(...);
oExcFirstInstance.Workbooks.Open(...);
oExcSecondInstance.Workbooks.Open(...);
oExcSecondInstance.Workbooks.Open(...);
oExcSecondInstance.Workbooks.Open(...);
这篇关于C#WebBrowser和Excel实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文