the contentType attribute
I'm working on a JSP page that displays a report and wanted to allow the user to display the content either in HTML (the default) or as an Excel spreadsheet. According to Marty Halls book, Core Servlets and JavaServer Pages, Excel is able to interpret HTML tables and all one needs to do is simply set the contentType to "application/vnd.ms-excel".
String format = request.getParameter("format");
if((format != null) && (format.equals("excel")))
So I did, and it worked, except for one little glitch. In the first column labelled "Days Missed", in the report, I have strings that are either 1-3, or 4-6 or 8-10 (obviously these indicate a range of days missed). When Excel loads these values it mistakenly displays them as date fields: 01-Mar, 04-Jun, 07-Sep.
Is there some way to rig this so that Excel doesn't interpret the strings as dates?