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

Sponsored Links

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  
Old April 29th, 2008, 02:38 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old April 29th, 2008, 02:57 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server 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
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old April 29th, 2008, 02:58 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old April 29th, 2008, 03:11 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server 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  
Old April 30th, 2008, 10:33 AM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old April 30th, 2008, 11:35 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server 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  
Old April 30th, 2008, 11:41 AM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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  
Old May 1st, 2008, 09:21 PM
Barn Newbie

 
Join Date: Mar 2008
Posts: 40
Thanks: 0
Thanked 4 Times in 4 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
Reply With Quote
  #9  
Old May 2nd, 2008, 09:31 AM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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


All times are GMT -4. The time now is 06:40 PM.



Content Relevant URLs by vBSEO 3.2.0