我写打开一个Excel工作簿把一些值的VB .NET程序。 下面是打开文件的代码:打开Excel文件的.NET Framework 3.5
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Excel files (*.xls)|*.xls"
OpenFileDialog1.ShowDialog()
filePath = OpenFileDialog1.FileName
If System.IO.File.Exists(filePath) Then
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBook = oExcel.Workbooks.Open(filePath)
End If
这个工作顺利,直到我不得不在一台旧电脑运行至极它没有.NET框架4.5,也不4.0
然后我改变框架目标3.5,它给了我这个错误中运行时:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll
Additional information: Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
我想打开一个Excel文件的方式是不一样的3.5或4.5,所以我不知道应该怎么办。
你在编译时是否也针对x86或x64?根据您的Office版本,它可能需要x86。 –