-
Excel
Hi,
I have created an HTML report. Very basic - all it does is read thru
a table in the database and for each record read, it displays it on the page. I now want to give the user the facility to be able to save this report in Excel. IE. click on a button and then save it to .xls OR it can be displayed in Excel immediately - without the user clicking a button.
I have heard that you just need to put some or other tag in the
meta tag!!??
Any ideas?
Thx, L
-
You can write a .csv file to the server and redirect to it. If the user has Excel installed, it will open inside of IE..
-
As the very first line on your page, try this
Code:
<%
Response.ContentType = "application/vnd.ms-excel"
%>
I use this type of thing a lot to provide a option of the report going to an HTML page, or a Word document (I have a check box, which if checked, sends the output to Word). It should work the same for Excel although I've not tried Excel yet. :)
-
Hey Hack can you tell me a site with a tutorial on that? Or what book you use? Thanx
-
Thank you Hack.
I got it going, but do you know how I can specify the columns in which the data must be written.
I read 3 variables from my table and want to write each field in a different column.
IE. Names in Column B, Surnames in Column D and Phone in Column F.
You know what I mean??
-
Here's an example of a small, but complete ASP-page. It's stunningly simple :)
Code:
<%@ Language="VBScript" %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%>
<table border="1">
<tr>
<th>Column A</th>
<th>Column B</th>
<th>Totals Column</th>
</tr>
<tr>
<td>4</td>
<td>3</td>
<td><font color="red">=sum(a2:b2)</font></td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td><font color="red">=sum(a3:b3)</font></td>
</tr>
</table>
Good luck!