Skip to main content
Participant
August 6, 2009
Question

creating excel sheet using coldfusion

  • August 6, 2009
  • 2 replies
  • 1095 views

hi,

i'm creating excel sheet from colfusion, and i want to include conditional formatting eg. if value>10 , bgcolor="red"

please let me know how can i do this?

thanks in advance.

    This topic has been closed for replies.

    2 replies

    Inspiring
    August 11, 2009

    Depending on what your development schedule is like, it may be worth holding off until CF9 comes (fall, I think?) - the <cfspreadsheet> tag looks like its exactly what you need.  Barring that, I think the already suggested solutions should work for you.

    Dileep_NR
    Inspiring
    August 6, 2009

    Hi

    refer

    http://www.bennadel.com/blog/435-Creating-And-Streaming-Simple-Microsoft-Excel-Files-With-ColdFusion.htm

    OR

    http://www.bennadel.com/blog/917-Creating-Excel-Files-With-ColdFusion-XML-And-POI.htm

    August 7, 2009

    Turns out that if you output html tables and cells as an excel file, the cells automatically adjust into excel sheet.

    The following sample should help you figure out.

    <cfheader name="CONTENT-DISPOSITION" value="attachment; filename=nameoffile.xls">
    <cfcontent type="application/vnd.ms-excel" reset="yes">

    <cfset getfields = 'CompanyName,BusinessAddress,BusinessPhone'>

    <cfquery name="getquery" datasource="#yourdsn#" dbtype="ODBC">

    select #getfields# from table

    </cfquery>

    <table>
    <tr>
    <cfloop index="getitem" list="#getfields#">
    <td><cfoutput>#getitem#</cfoutput></td>
    </cfloop>
    </tr>
    <cfloop query="getquery">
    <tr>
    <cfloop index="getitem" list="#getfields#">
    <td><cfoutput>#evaluate(getitem)#</cfoutput></td>
    </cfloop>
    </tr>
    </cfloop>
    </table>