Skip to main content
Inspiring
April 23, 2008
Question

Report output

  • April 23, 2008
  • 1 reply
  • 490 views
I usually output my report in a table like this :
<table>
<cfoutput query="qry">
<tr>
<td>#field_1#</td><td>#field_2#</td><td>#date_field#</td>
</tr>
</cfoutput>
</table>

This works fine and my output looks like this :

Field 1 Field 2 Date
12345 ABC 1/1/2008
12345 XYZ 1/2/2008
12345 mmm 1/2/2008
12345 zzz 1/3/2008

What I need to do is to rearrange the output to look like this, one row per instead of multiple columns :

12345 ABC 1/1/2008 XYZ 1/2/2008 mmm 1/2/2008 zzz 1/3/2008

How do I do this ? And what about the headings ? It can vary from 1 to any number, so how can I accomodate that also ?

thanks
    This topic has been closed for replies.

    1 reply

    Inspiring
    April 23, 2008
    trojnfn wrote:
    > How do I do this ?

    Anyway you want. Here is one since I have 1/2 an hour to kill.

    <cfoutput query="qry" group="field_1">
    #field_1#
    <cfoutput>
    #field_2# #date_field#
    </cfoutput>
    <br/>
    </cfoutput>
    trojnfnAuthor
    Inspiring
    April 23, 2008
    This works great !

    How can I export this to excel ?

    I normally use something like this below, which works fine, since all the columns and rows are defined. But using this cfoutput method to display the data does not seem to work with this excel method.

    <cfcontent type="application/msexcel">

    <cfheader name="Content-Disposition" value="filename=offsite_report.xls">

    <cfoutput>
    <table cols="13">
    <tr bgcolor="silver">
    <th>Create Date</th>
    <th>Ticket Number</th>
    <th>From ID</th>
    <th>From Name</th>
    <th>From Location</th>
    <th>From Mail Stop</th>
    <th>From Room Number</th>
    <th>To ID</th>
    <th>To Name</th>
    <th>To Location</th>
    <th>To Mail Stop</th>
    <th>To Room Number</th>
    <th>Handling Instructions</th>
    </tr>
    <cfloop query="qryGet_Offsite_Scans">
    <tr bgcolor="###iif(qryGet_Offsite_Scans.currentrow MOD 2, DE('F0FFF0'),DE('FFFACD'))#">
    <td>#dateformat(qryGet_Offsite_Scans.createdate,"mm/dd/yyyy")#</td>
    <td>#qryGet_Offsite_Scans.movenumber#</td>
    <td>#qryGet_Offsite_Scans.fromid#</td>
    <td>#qryGet_Offsite_Scans.fromname#</td>
    <td>#qryGet_Offsite_Scans.fromlocation#</td>
    <td>#qryGet_Offsite_Scans.frommailstop#</td>
    <td>#qryGet_Offsite_Scans.fromroomnumber#</td>
    <td>#qryGet_Offsite_Scans.toid#</td>
    <td>#qryGet_Offsite_Scans.toname#</td>
    <td>#qryGet_Offsite_Scans.tolocation#</td>
    <td>#qryGet_Offsite_Scans.tomailstop#</td>
    <td>#qryGet_Offsite_Scans.toroomnumber#</td>
    <td>#qryGet_offsite_scans.handlinginstructions#</td>
    </tr>
    </cfloop>
    </table>
    </cfoutput>
    </body>