我正在尝试通过以下代码访问 Excel 文件:
Microsoft.Office.Interop.Excel.Application ObjExcel
= new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook book;
Microsoft.Office.Interop.Excel.Worksheet sheet;
Excel.Range range1 = null, range2 = null;
CultureInfo ci = new CultureInfo("en-US");
Thread thisThread = Thread.CurrentThread;
thisThread.CurrentCulture = new CultureInfo("en-US");
book = ObjExcel.Workbooks.Open(LinguisticInstructionsFileName);
最后一行 book 变量的内容是System.__ComObject
在不同的应用程序代码正在工作并且变量有...Excel.WorkbookClass
。
所以我想问一下这种奇怪行为的原因可能是什么。我已经尝试使用额外的 Missing.Value 参数调用 Workbooks.Open 但结果是一样的。