Copy link to clipboard
Copied
I already have a very complex dynamic query the displays a list on the webpage. Now I need to pass this result set as object or csv or xml to CFR and produce a report.
how to do this?
Copy link to clipboard
Copied
Hi jolakammu,
You may try something like the below code:-
<cfquery name = "query_name" dataSource = "db_name">
select * from table_name
</cfquery>
<cfspreadsheet
action = "write"
filename="AgentReport.xls"
query="query_name"
overwrite="true">
<cfform>
<input type="button" value="Report Download" onClick="window.location.href='AgentReport.xls'">
</cfform>
Regards,
Anit Kumar
Copy link to clipboard
Copied
May be I was not clear on my question. Now how to pass this data to a coldfusion report and generate nice looking (header, footer, body, bolding , page number, grouping etc) report as pdf. Thanks.
I mean, how to make this csv as a datasource and create a report template (.cfr)
Copy link to clipboard
Copied
Here this is a simple example of generating report using query object by "cfreport" tag and report template.
http://coldfusion-tip.blogspot.com/2013/11/using-coldfusion-report-template-to.html
If you want to use a CSV data in report template then I think you need to convert CSV into Query object then follow the process descriobed in the above URL.
For CSV to Query coversion, you may refrer following links or you can write your own functon:
http://cflib.org/udf/CSVToQuery
http://www.bennadel.com/blog/501-Parsing-CSV-Values-In-To-A-ColdFusion-Query.htm
For more knowledge about ColdFusion reporting please refer following links: