Adobe Coldfusion Help: Query To Spreadsheet
COLDFUSION HELP TIP: QUERY to SPREADSHEET
I've been using Adobe ColdFusion for a number of years. Everyday, I come across something new that I have not seen or done. I was hoping to help others with some sample code to everyday situations that would occur. I'm asked to generate an Excel spreadsheet from SQL data often. Below is my sample code.
<!--- ---- query table for data ----------------- --->
<CFQUERY NAME="get_records" DATASOURCE="sampledata">
<cfif get_records.recordcount GTE 66000>
<!--- Excel can only handle 66000 rows --->
Too many records
<cfif get_records.recordcount GT 0>
<!--- create the file to be written --->
<cffile action="WRITE" file="d:\inetpub\domains\employee\www\data\filename.xls" output="
</tr> " addnewline="Yes">
<!--- append the dynamic data to the file --->
<!--- end your table in the file --->
</table> " addnewline="Yes">
Other ColdFusion Articles
- Adobe Coldfusion Tip For Finding Duplicate Records In SQL Database
- Coldfusion: allowing max file size when uploading
- ColdFusion: Monitor Hard Drive Space And Email Alert
- Coldfusion SQL Tips: Creating Tables, Backup, Fields
- Coldfusion Programming: Accessing a shared network drive
- Coldfusion: Encrypting and Decrypting Data
- Adobe Coldfusion Help: Query To Spreadsheet
- ColdFusion: Upload a pipe delimited file and insert into SQL table
- Coldfusion programming: How to submit muliple records at the same time that have the same field name
- How To Upload Multiple Files With ColdFusion
Once the routine executes, and there are no errors. The xls file will be written to the location specified in the code. In the sample, the xls file would be written to, d:\inetpub\domains\employee\www\data\filename.xls.
From here you could email the file, or just generate a link, so the user can download the file directly from the page.
More by this Author
This article will tell you how to make your baby's powder formula more consistent like the premixed ready-to-feed formula. You will save money using the powder and your baby won't know the difference!
Until this year, the only time that I've had mice or rats in the house were when my daughter had pet mice and rats, and one of those times we did have one loose in the house. (Science fair project got loose.) Anyway,...
You may refer to a truss as the rafter, but it's basically the skeleton of the roof, carrying the weight of the frame and supporting the walls of the building. Trusses are very important to preventing the walls from...