编程找到一个Excel文件的Excel版本 [英] Programmatically finding an Excel file's Excel version

查看:165
本文介绍了编程找到一个Excel文件的Excel版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个OleDbConnection连接到从C#程序A S preadsheet。其中一个连接字符串中的参数是Excel版本。

I'm using an OleDbConnection to connect to a spreadsheet from a C# program. One of the parameters in the connection string is the Excel version.

供应商= Microsoft.Jet.OLEDB.4.0;数据源= C:\\ Book1.xls的;扩展属性=的Excel 8.0 ; HDR = YES

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties="Excel 8.0;HDR=YES"

由于一个Excel文件我怎么能找出其中的Excel格式的版本,它使用?路径

Given the path of an Excel file how can I find out which Excel format version it uses?

由于提前,

T

推荐答案

下载<一个href=\"http://www.microsoft.com/downloads/details.aspx?FamilyId=9BA6FAC6-520B-4A0A-878A-53EC8300C4C2&displaylang=en\"相对=nofollow> OLE文件属性阅读器。注册dsofile.dll以regsvr32并将其添加为您的应用提供参考。下面code将输出Excel文件的类型。它不会在XLSX / DOCX工作,因为这些都不是OLE对象朱侃,陈万平文件,但应在所有旧的Office格式的工作(2007/2003 / XP)。

Download OLE File Property Reader. Register dsofile.dll with regsvr32 and add it as a reference in your application. The following code will output the type of Excel file. It will not work on xlsx/docx since those are not OLE compunds object files, but should work on all older Office formats (2007/2003/XP).

var doc = new OleDocumentPropertiesClass();            
doc.Open(@"c:\spreadhseet.xls", false, dsoFileOpenOptions.dsoOptionDefault);
Console.WriteLine(doc.OleDocumentType);

这篇关于编程找到一个Excel文件的Excel版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆