ASP calls Excel data directly

zhaozj2021-02-16  53

There is an Excel table book1.xsl in "c: /excel/book1.xls", the structure of the table is as follows:

1 serial number name amount

2 1 three 100

3 2 Li Si 200

4 3 Wang 500

The serial number field is not empty

Note: Excel starting 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 "

"

While Xlsheet.cells (i, 1) <> ""

response.write "

"

Response.write "

" & xlsheet.cells (i, 1) & ""

Response.write "

" & xlsheet.cells (i, 2) & ""

Response.write "

" & xlsheet.cells (i, 3) & ""

Response.write ""

i = i 1

Wend

Response.write ""

Set Xlsheet = Nothing

Set XLBook = Nothing

XLapp.quit 'Remember to add this sentence, otherwise an Excel process is added every time your machine is running, and it cannot be released.

转载请注明原文地址:https://www.9cbs.com/read-20833.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.042, SQL: 9