This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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" %> <html> <head> <title>Delivery Status</title> </head> <body> <% response.setContentType("application/vnd.ms-excel"); %> <jsp:include page="./config/mydomain/reports/Plane_US1A.csv" /> </body> </html> ======== 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 Thanks! Brian
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 ]