This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Opening CSV file in browser  RSS feed

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to display a .csv file in the browser using microsoft excel.
What should be set for response.setContentType("??");
I tried using res.setContentType("application/vnd.ms-excel");
but the file was opened as type .xls i.e. it ignored the commas.
Thanks
Pradeep
[ August 20, 2002: Message edited by: Pradeep Bhat ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"text/comma-separated-values" as the MIME type. This should work also ensure the url that inks to this does NOT include the xls extention, if you provide any extention use csv.
 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used it many times. Should work:
response.setContentType("text/csv");
response.setHeader("Content-Disposition","filename=\"" + filename + "\";");
out = response.getWriter();
//then just write to out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!