How to import data from a table into an excel file in asp

Source: Internet
Author: User
Recently, I just created a project that requires that the data extracted from the series Data Library on the asp page be saved as an excel file, at the beginning, I finally thought about it and shared it with you !!
---------------------------------------
The script is as follows: <%
Dim Rs_code, SQL _code, Rs_date, SQL _date
If Request ("Op") = "Show" Then
Sborder = "0"
Sbg1 = "bgcolor = Black"
Sbg2 = "bgcolor = White"
Else
Sborder = "1"
Sbg1 = ""
Sbg2 = ""
If Request ("Op") = "Excel" Then
Response. ContentType = "application/msexcel"
Response. AddHeader "Content-disposition", "inline; filename=1.xls"
ElseIf Request ("Op") = "DownLoad" Then
Response. ContentType = "application/msexcel"
FileName = "(" & Request ("sYear") & "-" & Request ("sMonth ")&") * ********** (the name of the program to be created here, defined by yourself )"
Response. AddHeader "Content-disposition", "attachment; filename =" & FileName & ". xls"
End If
End If
%>
On the upper-layer page, you must send the following parameters to the page: QH_TJ_C_imbark.asp? Op = Show
--------------------------------------------
In the program to convert to excel output, you must add in the following section:
<Table width = "875" border = <% = sborder %> cellspacing = "1" cellpadding = "1" align = "center" <% = sbg1 %>
---------------------------------------------
<Tr <% = sbg2 %>
---------------------------------------------
After the above preparations, you can write the program you want to do.

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.