There are many examples on the internet of doing this type of thing. But none of them work in Firefox. So I thought I'd set the challenge for Stack Overflow users.
Basically I need a very easy to use way for a user of a page to get the results of a query into the clipboard so that they can paste it into excel.
It can either be getting the data from a HTML table (generated by the query)
Or send the results directly to the clipboard (in a format readable by excel)
I have an intranet with many asp pages. Some of them generate quite large tables and some of these are then copied into excel. currently the user has to click inside the top left cell, then scroll down the page and move the cursor off the end of the table. If they don't do this exactly right (in Firefox) the data won't be read properly by excel.
I want them to just be able to click a button then they go to excel, click in cell a1, and ctrl-v. The data should show up properly separated into columns and rows (formatting doesn't matter)
Any ideas?
I am open to ASP or Javascript methods. And it must work in both IE and firefox (3)
EDIT
I've chosen the simplest option from the replies (I may have a lot of pages to 'do' so the simplest will be the best.
In the form...
Send results to excel <input type="checkbox" name="sendtoexcel">
In the code later on...
if request.querystring("sendtoexcel") = "on" then
response.contenttype = "application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment; filename=fname.xls"
end if