Copy link to clipboard
Copied
I have a fast-and-dirty requirement (CF8) which needs a fast-and-dirty solution ... "hacks welcome." I'd like to stumble-upon existing code that does as much of this work for me as possible.
I've got a table of queries. (That is to say, one of the columns is a text column containing a known-good SQL statement.) Those queries might contain a few parameters, and I've arranged for those to be identified in #some_name# syntax, within the text, just for simplicity All of these parameters are, and always will be, "dates."
The application is internal-only and the user is trustworthy. "Hijacking," injection and so forth is not a concern.
The user needs to be able to choose a query, enter the parameters needed, and poof, out pops a page in Microsoft Excel containing the query results.
I can see from a quick Google search that "this requirement has been done to death." So, can anyone quickly point me to the closest thing they've stumbled-upon that matches these requirements? Yes, I want to be lazy.
Copy link to clipboard
Copied
On your form, have some text boxes or something that enables the user to enter dates in yyyy-mm-dd format.
When processing the form, replace, #some_name# with {d '#form.variable#'}
Run query
do a google search on coldfusion excel poi to find the cfc that makes it easy to export query results to excel and actually plays nicely with excel 2007.
Copy link to clipboard
Copied
I found the following very satisfactory answer, and in fairly short order: (Assumes Excel 2003 or better.)
Even though the file is an XML file, Excel understands it perfectly.
Now... how'd I find all this stuff out, so fast? Yep! "Google it!" There are plenty of code-samples that illustrate the technique. (Disregard any that don't use XML. Ones that require special APIs are also unnecessary.)