Link to home
Start Free TrialLog in
Avatar of mudface061200
mudface061200

asked on

ASP to Excel

I have an HTML table that I want the user to be able to save to Excel.  What is the best way to do this?  Thanks.

-m
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Avatar of mudface061200
mudface061200

ASKER

The link you have provided is the opposite of what I need.  I have a table in HTML that I want to save to Excel.  The link you gave me is reading an Excel file into HTML..

Thanks anyway.
-m
ASKER CERTIFIED SOLUTION
Avatar of bruno
bruno
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
just change the content type to application/vnd-excel before outputting the table.


example:


<%response.contenttype="application/vnd-excel"%>
<table>
<tr>
<td>15</td>
<td>20</td>
<td>=$A1+$A2</td>
</tr>
</table>
dredge,

that's the same solution i posted.


BRUNO
So I can't have any <% %> tags after I say response.contenttype="application/vnd-excel"?
I guess I am not convinced just yet.  =)

 I understand that response.contenttype="application/vnd-excel"
makes the entire page an excel file, but I only want the table.  The table is created in a function.  So basically I need to, when the user clicks on "Export to Excel" for example, say response.contenttype="application/vnd-excel" then recall the table creating function.  Could you provide a couple lines of code?  Thanks.

-m
mudface,

be convinced, it's the best way to do it.  you can use asp tags after that, you can dynamically choose your data to export if you want.  there is more info here (last question in the bottom right frame) :
http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dn_voices_webmen/html/webteam07032000.asp


Good luck and let me know if more help is needed.

BRUNO
If you really don't believe me, check my profile I've answered this same question 3 times before with good results.  :-)

for even more info and a working example check here:

http://www.devx.com/webdev/discussions/101001/default.asp

read the section called "Create Excel Files Dynamically"


you can do the same thing for Word as well...
http://www.codeave.com/asp/code.asp?u_log=129


Good luck!

BRUNO
Do you want want to save the entire table including HTML tags or just the table contents?

Plus the article I posted could be used in what you require if you just read between the lines...
brunobear,

I don't question your ability to answer questions.  =)  I am just trying to figure out how to recall my function and add the

response.contenttype="application/vnd-excel"

to it.

understood.  :-)

check the links, there is some example code there.  If you need more help, feel free to post some of your code and perhaps we can help a bit that way.  

you might want to have the table created on it's own page, we had something similar to this and on the one page the user could choose which fields they wanted exported, and then they clicked the submit button, it went to the next page where it grabbed the correct fields and exported as Excel.

BRUNO
Sorry, to leave this open for so long.  I sorta forgot about it.

Thanks to all who submitted suggestions!  =)

-m
mudface,

thanks for coming back, and thanks for the A!


BRUNO
Is there anyway to do this from within the client's <script language="vbscript"> tag?