access data to excel using asp


K

Kevin Payne

Hello,

I have an intranet application written in asp using access as the backend
database. My users have requested they be able to download certain data into
an excel spreadsheet. I have limited asp experience and could use some help.

Ideally, the user would be prompted to save and name the file (save as
dialogue) and then the data would be selected and saved into that file. I
know I can use a select statement to select data directly into an excel
spreadsheet using:

SELECT * INTO [Excel 8.0;Database=" & lcPathFile & "].[Sheet1] FROM myTable

But I'm not sure that is the right approach. Any pointers in the right
direction greatly appreciated...

Thanks,
Kevin
 
Ad

Advertisements

R

Ray Costanzo [MVP]

If you already have an ordinary table of data in a page, you can turn that
into a spreadsheet and prompt a download as so. Paste this into a page
called "thisfile.asp" load it, and click the link to see what I mean.


thisfile.asp:

<%
Dim i
i = Request.Querystring("excel") & "0"
If CBool(i) Then
'Response.ContentType = "application/vnd.ms-excel"
'uncomment that^, comment that\/ to NOT prompt download dialg
Response.ContentType = "Kevin's Type!"
Response.AddHeader "Content-Disposition","attachment;
filename=report.xls"
Else
Response.Write "<a href=""thisfile.asp?excel=1"">Save as XLS</a>"
End If
%>
<table>
<tr>
<td>Cell A2</td>
<td>Cell B2</td>
</tr>

<tr>
<td colspan="2">Cell A3, as A3 and B3 merged</td>
</tr>
</table>


Ray at home
 

Top