Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exporting to csv or excel spreadsheet

Status
Not open for further replies.

cfdeveloper

Programmer
Nov 20, 2003
144
GB
Hello everybody,

I've written this code that exports the search results to a csv file. Here is the code:

<CFFILE ACTION="Write"
FILE="searchResults.csv"
ADDNEWLINE="Yes"
OUTPUT="Date, Ref, Name #Chr(10)##Chr(10)#">

<CFSET QUOTE = Chr(127)>
<cfoutput query="qSearch">
<CFSET log_string = QUOTE & LogTime & QUOTE & ","
& QUOTE & Reference & QUOTE & ","
& QUOTE & FirstName & QUOTE>

<CFFILE ACTION="Append"
FILE="searchResults.csv"
ADDNEWLINE="Yes"
OUTPUT="#log_string#">
</cfoutput>

<CFHEADER NAME="Content-Type" VALUE="application/unknown">
<CFHEADER NAME="Content-Disposition" VALUE="inline; filename=searchResults.csv">
<CFCONTENT TYPE="application/msexcel" FILE="searchResults.csv" deletefile="Yes">


I was wondering if its possible that when the display the header information (Date, Ref, Name)
with some background colour formatting to the text.

So for example when the above code is executed, the .csv file opens up with 3 columns:

Date Ref Name
20/08/2004 T123345 Joe Bloggs

Can I specify something in the code to for example make the header text colour to blue. If yes,
can someone please show me the code or give me some tips.

Best regards
cfcoder
 
No, <CFFILE> writes a text file. Since text files have no encoding for color it is impossible. Now if there were a way to export to an Excel (.xls) or Word (.doc, .rtf) file then you may be able to do it but I don't know how.

-Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top