Hi Jeff,
Go through the following :
---------------------------------------------
There is an elegantly simple and little-known way to get information from the server into Excel and Word, available in Office 97 and later versions. The key: Content-type. Excel and Word both can interpret HTML. This little trick means that you can use exactly the same ASP file and output it to Word, Excel, or the browser just by setting the content-type. Once it's in the viewer's Office applications, the viewer can do whatever he or she might want to do with any Office document, except save it back to the server.One limitation is that you can display only a single Excel sheet, rather than a workbook full. Because this is all simple HTML, the files are quite small. This makes a great, lightweight method of making reports available to those who might have slow connections.
Here is a simple example:
<%@ language=vbscript %><%response.buffer = true
response.ContentType = "application/vnd.ms-excel"
response.AddHeader "content-disposition", "inline; filename=dynamic.xls"
response.write "
"
response.write "
"
for i = 1 to 4
response.write "
"
response.write i + i
response.write " |
"next
response.write "
=sum(A1:D1) |
"
response.write "
"
response.write "
"
response.flush
response.end%>
There are several cool things to notice here.
The fourth line of the code does the magic of telling the browser which application to open. To open Word, you would change the content-type to application/vnd.ms-word.The fifth line of the code is a response.addHeader. This line specifies the file name to display if the user chooses to save, rather than open, the file.The line after the end of the for loop contains a sum formula that Excel will act upon correctly?and because of the tags that surround it, it will be disp