|
-
Nov 19th, 2002, 10:09 AM
#1
Thread Starter
Junior Member
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
-
Nov 19th, 2002, 11:53 AM
#2
Frenzied Member
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..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Nov 19th, 2002, 12:26 PM
#3
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.
-
Nov 19th, 2002, 06:17 PM
#4
Hyperactive Member
Hey Hack can you tell me a site with a tutorial on that? Or what book you use? Thanx
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Nov 20th, 2002, 05:41 AM
#5
Thread Starter
Junior Member
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??
-
Nov 20th, 2002, 06:40 AM
#6
Fanatic Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|