Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

CSV file to open in Excel

Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble getting a CSV file to open up in Excel. I have a .jsp page that links to another JSP page that has the following:
<%@ page language="java" session="true" isErrorPage="false" %>
<title>Delivery Status</title>
<% response.setContentType("application/"); %>
<jsp:include page="./config/mydomain/reports/Plane_US1A.csv" />
It launches excel, but it always comes up blank. We are running on Weblogic 6.1 server on Unix and the .csv files are placed in a directory from another application. I've tried the content type as suggested by other people as "text/csv" or "text/comma-saparated-values", but they just prompt me with a dialog box to save the file.
Any suggestions would be greatly appreciated
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you change the .csv file to be formatted like an HTML table? If you can, you will find that it works great without any changes, unless your users are using really *old* versions of Excel. Excel 97 and above understand data formatted as an HTML table. If you do this, Excel will even recognize the cell backgrounds, fonts, colors, embedded hyperlinks, etc.
If not, you need to get rid of the HTML tags. I haven't actually tested the following, but it should be close:
Two things to note. 1) The funny way scriptlet tags are opened (the <% is at the end of a line instead of the beginning) is important. If you don't do that, your downloaded CSV file will contain blank lines in the front, which will give blank rows in your excel spreadsheet. 2) The if( true) return at the end of the last scriptlet is also important, so that you don't get blank lines and trailing spaces at the end of the CSV file.
[ December 02, 2002: Message edited by: Michael Zalewski ]
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic