www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Format columns for data intended for Excel

Threaded View

  1. #1
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    resolved [RESOLVED] Format columns for data intended for Excel

    Hello, everyone.

    I'm working on a document that runs a query, populates a <table> with the data, and then spits out an Excel sheet for the user to either open or save. I'm using the CFSCRIPT equivalent of CFCONTENT and CFHEADER to create the Excel file.

    Code:
      <cfscript>
        pc = getpagecontext().getresponse();
        pc.getresponse().setcontenttype('application/vnd-ms.excel');
        pc.setHeader("Content-Disposition","attachment;filename=ThisData_#DateFormat(now(),'yyyy-mm-dd')#.xls");
      </cfscript>
    Everything is working great, with one exception.

    One of the query columns that is being returned is a datatype of varchar(10) - the data is a 'month year' value like "May 2010" or "Jun 2011". If you look at the data in a browser, it appears in that format ("month year"). But when the Excel file is created, it shows up as "May-12" or "Dec-12" (regardless of the month, the date is always 12.)

    I'm pretty sure this is because in Excel the column is formatted as "General" when I need it to be "Text". Is there a way to tell CF that a particular column needs to be formatted in Excel a particular way?

    Thanks,

    ^_^
    Last edited by WolfShade; 11-08-2010 at 11:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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



Recent Articles