An example of an ASP calling Excel data directly (without ODBC)

Source: Internet
Author: User
excel|odbc| data flutter and 8/30/2001 4:52:49 PM add in Joy asp← return suites:
Example:
There is an Excel table book1.xsl in "C:\excel\book1.xls", and the table is structured as follows:
1 Ordinal name Amount
2 1 Sheets 3,100
3 2 Lee 4,200
4 3 King 5,300

The ordinal field is not empty
Note: The Excel start line is 1 instead of 0

<% @language =vbscript%>
<%

Set xlapp = server. CreateObject ("Excel.Application")

strsource = "C:\excel\book1.xls"

Set xlbook = XlApp.Workbooks.Open (strsource)
Set xlsheet = xlbook. Worksheets (1)

I=1
Response.Write "<table cellpadding=0 cellspacing=0 border=1 width=500>"
While Xlsheet.cells (i,1) <> ""

Response.Write "<tr>"
Response.Write "<td height=20 align=center width=100>" & Xlsheet. Cells (i, 1) & "</td>"
Response.Write "<td height=20 align=center width=200>" & Xlsheet. Cells (i, 2) & "</td>"
Response.Write "<td height=20 align=center width=200>" & Xlsheet. Cells (i, 3) & "</td>"
Response.Write "</tr>"
I=i+1

Wend
Response.Write "</table>"
Set xlsheet=nothing
Set xlbook=nothing
xlApp.Quit ' Remember to add this, or you will add an Excel process to your machine every time you run it, and you cannot release it. I've tried "set
Xlapp=nothing "is not going to work.
%>



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.