0
我以前曾经使用.Net excel集成过很多次,但从未见过这种行为。只要我调用Wookbooks集合对象中的Open方法,未来的所有代码都无法在子集中执行。该线程似乎挂在Excel应用程序上,但应用程序UI不冻结(也不是Excel)。.NET Excel Interop-代码在文件打开后停止
If(System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\MaterialCatalog.xlsx")) Then
Dim excelApp As Microsoft.Office.Interop.Excel.Application
excelApp = New Microsoft.Office.Interop.Excel.Application()
excelApp.Visible = True
Dim wb As Workbook
Console.Out.Write("this appears in console")
Dim path As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\MaterialCatalog.xlsx"
wb = excelApp.Workbooks.Open(path)
Console.Out.Write("past") 'continue other code
控制台将写入“这出现在控制台”,但不是“过去”。任何想法为什么这可能挂?
谢谢,