简体   繁体   中英

Check for Header Row in Uploaded Excel file Classic ASP

I am uploading and connecting to an Excel spreadsheet. So far, so good, I am able to read through all rows in it, and do what I need.

What I am facing now is sometimes I may have the same data layout, but no header row.

How can I make the determination if the 1st row in the spreadsheet is a header row or not?

This is using classic asp (I know uggg...), and ADODB.Connection

I suggest you use the HDR setting of the Microsoft Jet OLE DB Provider .

  • HDR=Yes ( default ) indicates that the the Jet provider will not include the 1st row in the record set.
  • HDR=No indicates that the Jet provider will include the 1st row in the record set.

You may supply a value for HDR in your connection string. For a reference, see http://www.connectionstrings.com/excel/ .

It seems that the Jet provider can detect whether or not the spreadsheet contains a header.

  • If the spreadsheet contains a header, the Jet provider captures the header as is.
  • If the spreadsheet doesn't contain a header, the Jet provider automatically labels the fields as F1 , F2 , F3 and so on.

Whether the header is given in the spreadsheet or generated by the Jet provider, it's the HDR setting that enables you to include the header or leave it off the retrieved record set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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