ASP export to Excel - text formatting problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmartmem
    New Member
    • Feb 2008
    • 87

    ASP export to Excel - text formatting problem

    Greetings,

    I have a Classic ASP-based webpage that, on the click of a button, generates a dynamic result set that exports into Microsoft Excel using the following method:

    Code:
    <% Response.ContentType = "application/vnd.ms-excel" %>
    There's one field in the Excel export that gets messed up because Excel reads it as a number, not text, so it looks like this: 9.1561282123729 7E+21. The field displays correctly when the recordset is displayed in the browser.

    Does anyone have any suggestions how I can pass the exported value to Excel so it will display correctly?

    Regards,

    j
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Excel prefers that you escape numerical values with an apostrophe ("'98765" instead of "98765"). Try that and see if it works.

    Jared

    Comment

    • jmartmem
      New Member
      • Feb 2008
      • 87

      #3
      Very clever, Jared. I didn't think of that. I put an apostrophe in the result set code and it works. The apostrophe appears in the field, but at least I can see the value now. Thanks.

      Comment

      Working...