ASP read EXCEL2000 articles

Source: Internet
Author: User
Tags dsn table name first row
I used ASP to read the EXCEL payroll, so I found some information on the Internet.
Write the following program for you :)
<%
'================================== ASP read EXCEL note ====================== ====================
'I) think of the XLS file (book) generated by Excel97 or Excel2000 as a database, and each worksheet (sheet) in it as a database table.
Ii) ADO assumes the name of the first row in Excel. Therefore, you must include the content of the first row in the defined range.
'Iii) the row title (field name) in Excel cannot contain numbers. The Excel driver may encounter errors in this case. For example, your line title is "F1"
'Iiii) if a column in your Excel worksheet contains both text and numbers, the ODBC driver of Excel cannot process the data type of this row, make sure that the data type of this column is consistent.
'E-mail: Kaxue@Hotmail.com QQ: 484110 HOMEPAGE: www.Flyday.net
'Sorting Time: Thursday, May 23,200 2 PM WIN2000SERVER + IIS5 passed the test
'================================================ ======================================
Dim Conn, Driver, DBPath, Rs
'Create a Connection object
Set Conn = Server. CreateObject ("ADODB. Connection ")
Driver = "Driver = {Microsoft Excel Driver (*. xls )};"
DBPath = "DBQ =" & Server. MapPath ("test.xls ")
'Call the Open method to Open the database
Conn. Open Driver & DBPath
'Dsn connection method
'Conn. Open "Dsn = test"
'Note that the table name must be written in the following format: "[table name $]"
SQL = "Select * From [Sheet1 $] where No. = 0"
Set Rs = Conn. Execute (SQL)
IF Rs. Eof And Rs. Bof Then
Response. write "The data you need is not found !! "
Else
Do While Not Rs. EOF
Response. write Rs ("name ")
Rs. MoveNext
Loop
End IF
Rs. Close
Set Rs = nothing
Conn. Close
Set Conn = Nothing
'Response. Write "successful! "
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.