我需要能够从我正在开发的一些 .NET 代码中检测我的计算机中安装的 Excel 版本。我目前正在使用应用程序版本为此,但它没有给我有关服务包的信息。
我宁愿避免这样的事情:http://www.mvps.org/access/api/api0065.htm
欢迎托管代码!
Public Shared Function GetExcelVersion() As Integer
Dim excel As Object = Nothing
Dim ver As Integer = 0
Dim build As Integer
Try
excel = CreateObject("Excel.Application")
ver = excel.Version
build = excel.Build
Catch ex As Exception
'Continue to finally sttmt
Finally
Try
Marshal.ReleaseComObject(excel)
Catch
End Try
GC.Collect()
End Try
Return ver
End Function
如果未找到 excel,则返回 0。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)