DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005

    the contentType attribute

    Hi there,

    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?


  2. #2
    Join Date
    Oct 2004
    ad a tick (`) in front of the 1-3 value
    this tells excell to interpret it as a string

  3. #3
    Join Date
    Feb 2005
    Hi ractoc,

    I tried your suggestion. It worked, kinda. I placed the tick character in front of the values like so: `1-3, or `4-6, etc.

    I thought the tick "`" was some kind of escape character and wouldn't appear when Excel parsed it. But it does appear. I can probably live with this but if there is a better way to make Excel interpret 1-3, or 4-6 as strings without any additional characters showing, I'd prefer that.

    Please advise,


  4. #4
    Join Date
    Oct 2004
    you could also look up the jxl.ja library
    This lets you create real excell file, instead of comma seperated files or HTML collumns
    Using this library, you can actually tell excell what type of data is in each cell.

Similar Threads

  1. Replies: 1
    Last Post: 10-31-2005, 01:57 PM
  2. Replies: 1
    Last Post: 03-15-2005, 05:15 PM
  3. Replies: 1
    Last Post: 04-26-2001, 03:20 AM
  4. Constraining Attribute Values
    By Brandon Forest in forum XML
    Replies: 0
    Last Post: 12-22-2000, 03:40 PM
  5. support for namespaces on attribute value
    By Noga Atsil in forum XML
    Replies: 1
    Last Post: 11-21-2000, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.