简体   繁体   English

是否可以通过没有标题行的ADO.NET访问Excel文件?

[英]Is it possible to access Excel file through ADO.NET that does NOT have a Header Row?

I have a formated Excel file, over which I do not have control, and I need to read the information contained in it. 我有一个格式化的Excel文件,该文件没有我的控制权,我需要阅读其中包含的信息。

The problem with the file is that the first few rows contain formated information and I can not modify that file nor I can not ask for a format change. 文件的问题在于,前几行包含格式化的信息,我无法修改该文件,也无法要求更改格式。

Is it possible then, to read such a file through ADO.Net? 然后可以通过ADO.Net读取这样的文件吗?

Thanks in advance, 提前致谢,

I think this article explains how to do this pretty well: http://support.microsoft.com/kb/316934 我认为本文说明了如何做到这一点: http : //support.microsoft.com/kb/316934

As for the lack of a header row... 至于缺少标题行...

With Excel workbooks, the first row in a range is the header row (or field names) by default. 对于Excel工作簿,默认情况下,范围的第一行是标题行(或字段名)。 If the first range does not contain headers, you can specify HDR=NO in the extended properties in your connection string. 如果第一个范围不包含标题,则可以在连接字符串的扩展属性中指定HDR = NO。 If you specify HDR=NO in the connection string, the Jet OLE DB provider automatically names the fields for you (F1 represents the first field, F2 represents the second field, and so on). 如果在连接字符串中指定HDR = NO,Jet OLE DB提供程序将自动为您命名字段(F1代表第一个字段,F2代表第二个字段,依此类推)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM