Copy link to clipboard
Copied
Hello, I hope you can help me.
I have to export to excel, 20 or so queries.
What I would like to do is set the date range on a form, and then click Submit. The submit would perform about 20 queries, one of the other and writing EACH to its own excel file. Is this possible?
The queries are exactly the same, except for one WHERE clause. I can pre-write the queries, all 20 of them, but how I do make them begin after the previous ends? And what would be the best way to have these write to a file upon completion?
Thanks guys
Copy link to clipboard
Copied
ColdFusion executes all statements in .cfm template, including queries, in sequential order (with some exceptions like cfexecute with certain attributes).
Thus, your question does not make sense to me. Can you specify a bit further?
-Fernis
Copy link to clipboard
Copied
But can you have it save the query data to file after each query is
run, all on the same page? Would you just have a separate for
each?
Copy link to clipboard
Copied
I don't see how - for example - using cfspreadsheet tag to save a query to a file is any different from, say, setting a variable with a value. If you do <cfset a = 1>, you certainly don't need a new .cfm page to set <cfset b = 2>. Similarly, writing many files from many queries on the same page is something you could logically do with any language or any middleware.
I must be missing something here, since I can't see how this is a problem...
It should be pretty easy to have a loop, and parameterize both filenames and cfquery data.
Maybe if you post some code example or detailed expalanation about how and what you want to do, people can help you further.
-Fernis
Copy link to clipboard
Copied
My original post just wanted to know if this was possible. I never said it
was a problem.
I am new to CF, have a basic understanding, but when it comes to writing
files I've only had experience writing a single file from a .cfm page. I
wrap the output table in a , etc.
With that, I wanted to add more queries and more outputs. Would the logic
just be the same?
Thanks,
Copy link to clipboard
Copied
Are you wanting to •save• the files (ie: to the server HDD), or do
you want to serve them to the client browser (ie: so the user can save
them to their HDD). Those are two different things. From your wording
it sounds like the former, but I suspect you want to do the latter..?
--
Adam
Copy link to clipboard
Copied
Yes, to my HDD. I will supply the path (%SYSTEMROOT%/reports).
Copy link to clipboard
Copied
Yes, that's completely possible in one page. You'd simply have 20 queries, and 20 CFSpreadsheet calls. Or stick them in a
CFLoop, if possible, but either way, completely doable.
Copy link to clipboard
Copied
Well, I'm using CF8 so what is the proper equivalent?
Copy link to clipboard
Copied
If .csv files are enough for you, then you can construct a variable and use cffile to save it as a .csv file.
See http://www.cflib.org/udf/CSVFormat for more.
If you really need .xls file and you don't have CF9, search Internet for "cfx_excel", "cf_excel" or "coldfusion query to excel", or use the Adobe Exchange to search for any excel related stuff for ColdFusion.
One starting point I found is http://querytoexcel.riaforge.org/ - never tried it. Hope you get lucky.
-Fernis
Find more inspiration, events, and resources on the new Adobe Community
Explore Now