Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Document from Query Results

Status
Not open for further replies.

Riversidos

Technical User
May 17, 2005
1
US
I have a way to create an Excel Spreadsheet from a query result but how would I create a Word Document from a query result?

Code:
<cfsetting enablecfoutputonly="Yes">
<cfheader name="Content-Disposition" value="inline; filename=xs.xls"> 
<cfcontent type="application/msexcel" file="xs.xls">

<cfoutput>
    <table cols="4">
        <cfloop query="QryGetQueryList">
            <tr>
                <td>#QryGetQueryList.Company#</td>
                <td>#QryGetQueryList.Country#</td>
                <td>#QryGetQueryList.State#</td>
            </tr>
        </cfloop>
    </table>
</cfoutput>
 
I've done this numerous times.

Format your page as you would like it to appear in MS Word (including fonts, highlighting, etc.) then add the following code AFTER your cfoutput end tag, but before your body tag:

Code:
<CFHEADER NAME="Content-Type" VALUE="application/msword">
<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=msword.doc">
 
Sorry, that should read:

AFTER your cfoutput end tag, but BEFORE your body END tag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top