DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Web Design > HTML & CSS Help

Discuss "Response Headers and Meta Tags" in the HTML & CSS Help forum.

HTML & CSS Help - Discuss HTML, DHTML, XHTML and Cascading Style Sheets (CSS) here. Get tips on how to design your web site.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old April 29th, 2008, 02:38 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default Response Headers and Meta Tags

Well, our users just love to have any tabular output downloadable as an Excel spreadsheet. I'm been trying to find a quick and easy way to do this and wondering why the following doesn't work as expected:
Code:
<html>
<head>
 <META http-equiv="Content-Disposition" content="attachment; filename=testdocument.xml">\n';
 <META http-equiv="Content-Type" content="application/vnd.ms-excel">\n';
<style type="text/css">
   td {padding:2em; background-color:yellow; border:1px dotted #000;}
</style>
</head>
<body>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>=sum(a1:d1)</td>
<td>3</td>
<td>4</td>
<td>1</td>
</tr>
</table>
</body>
</html>
If I understand META tags correctly (and probably don't) I should get excel to load with the resulting spreadsheet -- but only get a regular HTML page with an HTML table.

Interestingly (so far) the following works:
Code:
<%response.ContentType = "application/vnd.ms-excel"%>
<%response.AddHeader "Content-Disposition", "attachment; filename=testdocument"%>
<html>
and Excel opens up fine.

Before I drive myself more loony, have I got this wrong?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old April 29th, 2008, 02:57 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 543
Thanks: 14
Thanked 41 Times in 40 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft SQL Server Microsoft Windows Microsoft .Net Classic ASP 
Total Awards: 4

Default

What's with the /n'; at the end? I've never seen that used before in a meta tag.

Try running the ASP version and then view the page source to see what it outputs.
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old April 29th, 2008, 02:58 PM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Bah. A sloppy cut and paste I'm afraid.

The ASP version gives me the option to save as and xls file, which them opens in Excel. No option to view source
Reply With Quote
  #4 (permalink)  
Old April 29th, 2008, 03:11 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 543
Thanks: 14
Thanked 41 Times in 40 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft SQL Server Microsoft Windows Microsoft .Net Classic ASP 
Total Awards: 4

Default

Perhaps it's the order the tags are in...notice how the ASP version is in a different order. Try:
Code:
<meta http-equiv="Content-type" content="application/vnd.ms-excel">
<meta http-equiv="Content-Disposition" content="attachment; filename=testdocument.xls">
Reply With Quote
  #5 (permalink)  
Old April 30th, 2008, 10:33 AM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Tried reversing the meta tags -- even tried running this with the Cassini server -- all no-joy. When I view source, I see:
Code:
<html>
<head>
 <META http-equiv="Content-Disposition" content="attachment; filename=testdocument.xml">
 <META http-equiv="Content-Type" content="application/vnd.ms-excel"
So I guessing the tag is just being ignored.

Humpf!
Reply With Quote
  #6 (permalink)  
Old April 30th, 2008, 11:35 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 543
Thanks: 14
Thanked 41 Times in 40 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft SQL Server Microsoft Windows Microsoft .Net Classic ASP 
Total Awards: 4

Default

Interesting. I was able to duplicate this problem on my machine. I did some research and came up with nothing. Most people use some sort of server-side script to add these headers, whether it be php, ASP, or ASP.Net. I'm interested in seeing if anyone has any information on this.
Reply With Quote
  #7 (permalink)  
Old April 30th, 2008, 11:41 AM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Server side scripting is the tack I've normally taken with this -- just seem silly to do another trip to the server to generate something that I already have. Oh well.
Reply With Quote
  #8 (permalink)  
Old May 1st, 2008, 09:21 PM
lewy's Avatar
Alter Ego Wizard

 
Join Date: Mar 2008
Location: Edinburg, TX
Posts: 35
Thanks: 0
Thanked 3 Times in 3 Posts
Rep Power: 1
lewy is on a distinguished road
Default

You're trying to output formatted excel from server side right wolffy?

I've got an example laying around at work using c#, let me know if you'd like it
__________________
................... ASCII and ye shall receive ..................
Knowledge is the only resource on earth that multiplies when shared

If you found a post helpful, please click the 'Thanks' button in the lower right-hand corner of the post.
Reply With Quote
  #9 (permalink)  
Old May 2nd, 2008, 09:31 AM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 150
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Thanks for the offer Lewy, but my goal here was to do this on the CLIENT side. I've already got the table displayed in the browser and was hoping I could save another trip to the server (and oracle) by opening a new browser window on the client with the necessary header info to 'fool' IE6 (the only browser I need to support) into opening it as an excel spreadsheet.

Coldfusion (in which this puppy is written) seems to be able to set this header info using CF tags on the server -- so I have a server solution working.

Thank again
Reply With Quote
Reply

  DeveloperBarn Forums > Web Design > HTML & CSS Help

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 12:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46