cftopper.com

Free Query to Excel Function

generateExcel SampleI'm working on extending a system with excel reports so I knocked up a handy function that will turn any Query into an excel view.

Download


Syntax


The function generateQuery takes 4 arguments: the query, the columns, the mode and the filename. The syntax is:

generateExcel( theQuery, columnList, mode, filename  )

But you can call it with just the name of the query if you want, e.g.:

generateExcel( myQuery  )

Options


  • You can be specific about the columns:

    generateExcel( products, "productname, productCost" )

    The Column list argument allows you to specify the order you want the columns displayed in, or omit columns you don't want. If you want you can just leave it blank and it will just use the query column list - but the columns could be in any order.
  • There are 3 output modes: "display", "save" and "debug":

    generateExcel( products, "productId, productname, productCost", "save" )

    The default mode is "display".

    Mode "display": This will try to display the excel chart within the browser. If the end-user's browser does not allow this, Excel will launch and show the output instead.

    Mode: "save": This will just do a download and will not attempt to display within the browser.

    Mode: "debug": Will display the columns as a normal HTML page with <pre> tags.

  • The filename attribute allows you to specify the filename that the excel should be saved as. The default is "report.xls".

If you find this function useful, please just send me an email to say thanks peterATdigital-crew.com

Enjoy!

Update May 15 2007


I made some improvements yesterday - the code uses <cfcontent reset="yes"> so that it will reset the output before rendering the excel view and now supports exporting dates properly.
Tags: ColdFusion | Tools

My Lastest Masterpiece: ProFlashDownload

Cue Drumroll... my latest ColdFusion component is complete!

ProFlashDownload allows developers to make a list of files available for download to a user. These files will download with a progress bar and the developer can have a page called in the background when a file has completed downloading.

ProFlashDownload - Click for real demo

I was specifically asked to develop this component based on my existing work on ProFlashUpload.

Just like ProFlashUpload, ProFlashDownload is highly customizable, easy-to-use and easy-to-program.

Sidenote: You would think that Flash programming is browser-independent, but with this sucker, I had a bunch of issues with Internet Explorer causing all sorts of strange behaviour that I had to tediously program around.

Sidenote 2: It has been suggested that I combine ProFlashDownload and ProFlashUpload to make the mother of all web based file management utilities... and i'm considering it.

I'll be making this tag available for purchase at $50 on www.cftagstore.com in the coming days.

About Topper on ColdFusion

Peter Coppinger aka Topper is a neurotic web monster who spends most of his chaotic life developing ColdFusion web applications when not drinking himself into a stupor and scheming his plans for world dominance.

Peter founded Digital Crew way back in 1999. Digital Crew run CFTagStore.com and have also produced lots of powerful ColdFusion tools like ProFlashUpload and CFMyAdmin.

I made this site to share my thoughts, tips and tools with fellow ColdFusion developers.

If your a ColdFusion developer, go ahead and subscribe to this site and in exchange i'll try to provide quality content to make it worth your while.
RSS Feed for Topper on ColdFusion

I'm speaking at CF-United Europe!

CFDevCon I'm going to be speaking at CFDevCon08! It's my second time speaking in front of more than 10 people so please lend your support.

The topic is:
Introducting TeamworkCMS and Site Engine - Building better websites in half the time or something like that..

Digging

My Work - Just Finished

  • modules.cit.ie
    Web-=based modules/programmes designer tool and database system for Cork institute of technology.
  • Teamwork Project Manager
    The top secret project is finally released. The project management app will rock your world - give it a go.
  • PMG
    New website for Project Management Group website.
  • Digital Warehouse Wholesale
    Added wholesale products to existing client website.
  • New Digital Crew documentation website
    New version of documentation.digital-crew.com using new InfinityCMS site engine. It's done now. Just add content.
  • PFH Company Webite
    New website/CMS/Newsletter System for prestigious Irish IT company.
  • Module Manager for CIT
    CIT is switching to module based courses. We are making an application for managing/submitting these modules. Gettig there.
  • Bons Secours Cork Hospital Intranet
    New Intranet for Bons Secours hospital in Cork. Considering turning this Intranet system into stand-alone product.
  • Revamping InfinityCMS
    I'm making major improvements to our content management solution, InfinityCMS. Making it faster, more powerful and easier to check into/out-of source control. Done but it's always going to be evolving.
  • BPC Update
    Minor functionality update for internal Pfizer Best Process Chemistry project.