On the response attribute in ASP

Source: Internet
Author: User
At random to visit the time, see "ASP Use Response attribute" This article, think of the previous see a foreign related articles, dare not monopolize, take out and share.
Debugging is passed, but some words in English, but also please forgive us.
Here is how to use the ASP page to convert the form of Excel forms, we remember that there was a lot of shrimp said in the form of a DLL to solve, but this for large data volume, it is slow. If you use the method described in the article, you will not occupy the resources of the server, just open on the client. Another benefit is that the tables in the Web page look like what the table in Excel looks like. Well, then tell me an exciting message, except for tabular data, in Excel, like buttons are not displayed. This solves the problem of the printing of the webpage of our people, it is a lot of.
Cut the crap and get to the point.
To create a dynamic Excel report, you first write in an ASP file:
<%
Response.ContentType = "Application/vnd.ms-excel"
%>
(remember: This sentence must be written at the beginning of the article Yo, otherwise, hehe ....) )
This sentence tells the browser that the next code is in Excel format, and then the browser prompts you to save or open the file, and then you can open it or save it.
Look at one example first:
<%
Response.ContentType = "Application/vnd.ms-excel"
%>
<HTML>
<HEAD>
<link rel= "stylesheet" href= "STYLE. CSS ">
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<table border= "1" width= "100%" bordercolorlight= "#000080" bordercolordark= "#0000FF" height= "190" >
<tr>
&LT;TD width= "100%" colspan= "height=" >
<p align= "center" ><b> converted from ASP page to Excel report </b></td>
</tr>
<%for I=1 to 8%>
<tr>
&LT;TD width= "8%" height= "align=" "Center" ><%=1*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=2*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=3*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=4*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=5*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=6*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=7*i%></td>
&LT;TD width= "8%" height= "align=" "Center" ><%=8*i%></td>
&LT;TD width= "9%" height= "align=" "Center" ><%=9*i%></td>
&LT;TD width= "9%" height= "align=" "Center" ><%=10*i%></td>
&LT;TD width= "9%" height= "align=" "Center" ><%=11*i%></td>
&LT;TD width= "9%" height= "align=" "Center" ><%=12*i%></td>
</tr>
<%next%>
<tr>
<td>=sum (A2:A9) </td>
<td>=sum (B2:B9) </td>
<td>=sum (C2:C9) </td>
<td>=sum (D2:D9) </td>
<td>=sum (E2:E9) </td>
<td>=sum (F2:F9) </td>
<td>=sum (G2:G9) </td>
<td>=sum (H2:H9) </td>
<td>=sum (I2:i9) </td>
<td>=sum (j2:j9) </td>
<td>=sum (K2:K9) </td>
<td>=sum (L2:L9) </td>

</tr>
</table>
<p align=center><input Type=button value= "test" ></P>

</BODY>
</HTML>
Get this code on your machine and see how it works, haha, you're going to steal the music.
Wait, there's a little problem:
Microsoft has acknowledged a BUG in IE (3.02, 4.0, 4.01, 4.01SP1) which causes it to misinterpret Excel output, particular ly when generated by ASP, ISAPI, or CGI. Can read more about it at http://support.microsoft.com/support/kb/articles/q185/9/78.asp. To Summarize:when Internet Explorer connects to a WEB server resource this dynamically generates Word, Excel, or other Ac tive Documents, Internet Explorer may send two get requests for the resource. The second get usually does is not have sessions state information, temporary cookies, or authentication information have already been specified for the client. This bug can affect any local server (EXE) Active Document application hosted inside the Internet Explorer frame window. It occurs most frequently with ISAPI, ASP, or CGI applications This adjust the HTTP "Content Type" header to identify the Installed application.

I also encountered a problem: I put it on my own machine (WIN2000), it does not download or open to me, only to put it on the other webserver when debugging success.
If the brothers have any better tips, don't forget to tell me.


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.