access data to excel using asp


Kevin Payne


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...




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.


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

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

Ray at home

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question