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
控制檯將寫入「這出現在控制檯」,但不是「過去」。任何想法爲什麼這可能掛?
謝謝,