Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download from SQL to Excel sheet

Status
Not open for further replies.

aishaaa

Programmer
May 1, 2002
21
AE
Hi,

I have the below coding but it’s only displaying the data not saving it to excel I guess I have a problem with my coding please help me …

<HTML>
<HEAD>
<TITLE>Telex Transfer</TITLE>

<%

'response.setContentType &quot;application/excel.xls&quot;
'response.setHeader(&quot;Content-Disposition&quot;,&quot;filename=book1.xls&quot;)

set conn = Server.CreateObject(&quot;ADODB.CONNECTION&quot;)
set qryrs = Server.CreateObject(&quot;ADODB.RECORDSET&quot;)

conn.open &quot;DSN=OPP; UID= “”; Password=”;&quot;


SQL= &quot;select ReferenceNo, ValueDate, Currency, Amount, Narration from msgmain&quot;


set qryrs = conn.execute(SQL)
%>

</HEAD>

<BODY>
<form name=&quot;&quot;>


<table border=0 cellpadding=0 cellspacing=0 bordercolor=black style=&quot;width:100%&quot;>
<tr>
<td>ReferenceNo</td>
<td>ValueDate</td>
<td>Currency</td>
<td>Amount</td>
<td>Narration</td>
</tr>

<%While Not qryrs.eof%>
<tr>
<td><%=qryrs(&quot;ReferenceNo&quot;)%></td>
<td><%=qryrs(&quot;ValueDate&quot;)%></td>
<td><%=qryrs(&quot;Currency&quot;)%></td>
<td><%=qryrs(&quot;Amount&quot;)%></td>
<td><%=qryrs(&quot;Narration&quot;)%></td>
</tr>
<%qryrs.MoveNext
Wend%>
</table>

<%
qryrs.close
conn.close%>

</form>
</BODY>
</HTML>
 
Where exactly do you expect it to save to Excel?



AGIMA.net
 
If you want to create a new Excel Workbook and save it somewhere from an .asp page you're going to need a lot more to happen.
<%
'Change HTML header to specify Excel's MIME content type
Response.Buffer = TRUE
Response.ContentType = &quot;application/vnd.ms-excel&quot;
%>

With this at the top of your .asp page, if the user has Microsoft Excel installed, the page will be displayed as Microsoft Excel. The user can then do a 'Save As' and save the workbook where ever they want. Try it and see. Maybe this is all you need.
 
Thanks for the reply ... (AGIMA)i expected to open excel sheet with the data and user will save it ....

(Veep) i didnt get this one
<%
'Change HTML header to specify Excel's MIME content type
 
Headers and ContentTypes are part of the html header that your sending to the user. These need to be declared before you output any html to the user, otherwise IIS sends a generic set of headers. Headers only get sent one timefor each page, so in order for this to be sent as an excel file you will need to change those headers (similar to your commented out lines) before you pass it the
Code:
<html>
and
Code:
<head>
and etc tags

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
Thanks alot for your support .... i have done it ... and it's working fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top