我写了一个values程序,它打开一个.NET工作簿来放置一些值。以下是打开该文件的代码:
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 Framework4.5或4.0的旧电脑上运行它之前,它运行得很好
然后,我将Framework目标更改为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版本中是不一样的,所以我不知道该怎么做。
发布于 2014-03-26 23:49:43
也许你可以找到一些使用.Net 3.5的早期Interop Lib?
当我以Office 2010和2007为目标时,我发现如果我使用2010 Interop DLL,我也可以使用它们与2007和2003 Office进行对话。我不能使用任何只有在以后的版本中才有的功能。
这是从不同版本的.NET到3.5,我没有尝试更高的版本。不确定您是否使用与我和我相同的方法使用C#,但也不确定这是否重要。如果您使用的是32位Office,请确保构建x86 .net应用程序。
https://stackoverflow.com/questions/22666231
复制相似问题