Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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.