473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

xBrowser CSV Content Types

Hi,

Ive got a button on a page which creates a CSV and writes it to the
response stream for the user to download...

private void btnCSV_Click(object sender, EventArgs e)
{
Response.ContentType = "text/plain";
Response.AddHeader("content-disposition", "attachment; filename=
\"List.csv\"");
Response.Write(CreateCSV());
Response.End();
}

This works fine in IE.

In FF however, if i chose "open with excel" it saves the file in the
temp folder as "List.csv.xls", so when excel tries to open it it
thinks its an xls and doesnt parse it correctly as a csv :( If i save
it then open it, it of course works fine.

Is this just a problem with FF/Excel, or is there something i can do
with the content-type/other headers to fix this?

Thanks

Andrew

Mar 27 '07 #1
1 1447
If I had to take a guess, I would guess that it is one of two things:

1. Firefox is attempting to correct to known types (possible)
2. Firefox is calling a windows API call that corrects to known types
(probable)

Either way, the only way "around" the issue is to change to Excel (and
convert list to table) when you detect firefox and allow the user to save
off as CSV. There is probably another creative way around, but it is not
coming to mind at this point in time.

There were a lot of issues with the last NetScape/Microsoft fight in the
late nineties. As the web has become more complex, or rather "the browsers",
this second fight (Firefox, ultimately, comes from NetScape) is a bit
messier. It gets even more fun when you start dealing with "standards" and
how each side interprets them. :-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
<tr******@hotmail.comwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
Hi,

Ive got a button on a page which creates a CSV and writes it to the
response stream for the user to download...

private void btnCSV_Click(object sender, EventArgs e)
{
Response.ContentType = "text/plain";
Response.AddHeader("content-disposition", "attachment; filename=
\"List.csv\"");
Response.Write(CreateCSV());
Response.End();
}

This works fine in IE.

In FF however, if i chose "open with excel" it saves the file in the
temp folder as "List.csv.xls", so when excel tries to open it it
thinks its an xls and doesnt parse it correctly as a csv :( If i save
it then open it, it of course works fine.

Is this just a problem with FF/Excel, or is there something i can do
with the content-type/other headers to fix this?

Thanks

Andrew
Mar 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jonathan.beckett | last post by:
Hi All, For the past few months I have been working on an open source Apache/PHP/MySQL content management system - and have recently made it available for download. It's still very much a...
0
by: jonathan.beckett | last post by:
Hi All, I have just made version 0.4.8 of the PluggedOut CMS Content Management System available for download - it's free, and covered by the GPL. It's still very much a work in progress...
5
by: Richard Light | last post by:
A literal-minded reading of the XML 1.0 Spec suggests that elements with content model ANY should not have comments or PIs as their immediate children. Is there a particular reason for this? ...
17
by: ccdrbrg | last post by:
This is a rather general subject, I apologize. I am new to XHTML, CSS, et al and I am having trouble understanding the DTD and xml namespace declarations. For example: <!DOCTYPE html PUBLIC...
0
by: alexsink | last post by:
I am trying to get apache content negotiation to redirect only zh-CN(mainland China, where Simplified Chinese translations are available) language types to Chinese web pages, and have all other...
4
by: drclue | last post by:
I have this sorta nifty SVG speaker selection widget I'm developing. http://kirksaeter.com/SpeakerSelector/Assets/Images/SpeakerSelector.svg I've been regularly validating it ( minutes ago was most...
4
by: Janto Dreijer | last post by:
Hi! The Nokia Java SDK allows one to define multiple content-types in a single HTTP header field. I'm not sure if it's standard, but it's happening from some Java-enabled phones. This breaks...
14
by: Brad | last post by:
I have a .net 2.0 web application project that creates a pdf file, saves the pdf to disk (crystal reports does this part), and then my code reads the pdf file and writes it to the httpresponse ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.