• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem downloading CSV file in Internet Explorer.

 
Ranch Hand
Posts: 419
Mac jQuery Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am providing user an option to download CSV file from my application. If we don't save that file in the machine and instead of clicking save we click open in internet explorer it opens in Microsoft Excel and excel uses the file name as worksheet name. Now in this case what is happening that it shows me excel worksheet name as .csv[filename this is illegal name for excel worksheet and I get error for the same. In other case if I save this file on my machine and open it, it works fine. Can any one tell me is it the problem with my code or something else? I am using following content type to download this CSV file.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Google for "mime type csv" to find the correct MIME type of CSVs.
 
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Bellow example code will help you
Example
 
pawan chopra
Ranch Hand
Posts: 419
Mac jQuery Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vinoth, but the example couldn't resolve my problem. I think it is the problem with Microsoft Excel because the same thing is working fine in Microsoft Excel 2007. I was trying in 2003 version.
 
Vt Guru
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Excel 2003. It works fine.
 
pawan chopra
Ranch Hand
Posts: 419
Mac jQuery Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I have found the problem. actually what I have seen is when I am opening it in IE, it uses following naming convention to save file in temporary folder:

Portal_Activity_Visitors_1d_15-May-2009[1].csv

now [] this is not allowed for the name of excel worksheet. That is why I am getting error. But still I am not sure
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IE works out what to do with a file based on the Content-Type and Content-Disposition headers. If you have correctly set both of those (as Ulf suggested earlier) it should be OK. Windows uses the registry HKEY_CLASSES_ROOT/MIME/Database/Content-Type to map the Content-Type header to an application. Windows also has a concept called MIME sniffing whereby it has an algorithm that attempts to workout the MIME type of a binary file by analysing the first n bytes with varying degrees of success. Assuming you have correctly set the Content-Type MIME sniffing should not be playing a part, but if you are on XP SP2 or above you can disable it to make sure.

The file name doesn't matter to Excel. I can open a file names foo[1].bar[2] in Excel 2003 no problem. The square brakets stuff you see is a file name pattern that Excel itself can generate. Are you sure the error is about the file name and not a security warning that files of a particular type cannot be opened from a particular location? There is a bug in IE6 that (for security reasons) prevents certain applications opening files in the default temp file space.
reply
    Bookmark Topic Watch Topic
  • New Topic