Skip to main content
January 30, 2012
Answered

csv - coldfusion

  • January 30, 2012
  • 2 replies
  • 1754 views

I'm using <cfsavecontent> to load query data into a .csv file.  The data return is clean except for the end of the file i'm getting additional information from the coldfusion page like (see below).  How do I get rid of this additional information?

    </div>

    </div>

   <br clear="all" />

<div id="footer">

  <p>&copy; 2012

  <a href="http://www.user.edu/index.html">data</a> |

  <a href="http://www.user.edu/contactus/index.html">Contact Us</a> |

  <a href="http://www.user.edu/site.html">Using Our Site</a><br />

address info here </p>

</div>

<!--End Footer-->

<br clear="all" />

  </body>

</html>

    This topic has been closed for replies.
    Correct answer

    Thank you. I realized what the problem was, I needed to add the following

    <cfsetting enablecfoutputonly="Yes" showdebugoutput="no">

    THis solved the issue.  thanks.

    2 replies

    January 30, 2012

    here's the code:

    <body>
    <cfinclude template="/includes/header.cfm">
    <div id=container>
    <div id=maincontent>
    <cfsetting enablecfoutputonly="Yes">

    <cfcontent type="application/msexcel">
    <cfheader name="Content-Disposition" value="inline;filename=advisors2.csv">
    <cfsavecontent variable="csvFile">StNSUID,StPdm,StLn,StFn,AdPdm,AdNSUId,AdLN,AdFN,TCEff
    <cfoutput query="qAr">
    #StNSUID#,#StPdm#,#StLN#,#StFN#,#AdPdm#,#AdNSUID#,#AdLN#,#AdFN#,#TCEff##chr(10)#
    </cfoutput>
    </cfsavecontent> 
    <cfoutput>#csvFile#</cfoutput>
         </div>
        </div>
       <cfinclude template="/includes/footer.cfm">
      </body>
    </html>

    Legend
    January 30, 2012

    Most likely, your footer.cfm module includes cfoutput statements. My question would be, why are you using what appears to be a standard html template to output a csv and attempting to bypass the "standard" output with a enableoutputonly="yes" parameter? I would instead strip out all the "standard" code and simply output the csv. Something like this:

    ...

    Other logic, if necessary

    ...

    <cfsavecontent variable="csvFile">StNSUID,StPdm,StLn,StFn,AdPdm,AdNSUId,AdLN,AdFN,TC Eff

    <cfoutput query="qAr">

    #StNSUID#,#StPdm#,#StLN#,#StFN#,#AdPdm#,#AdNSUID#,#AdLN#,#AdFN#,#TCEff ##chr(10)#

    </cfoutput>

    </cfsavecontent>

    ...

    <cfheader name="Content-Disposition" value="inline;filename=advisors2.csv">

    <cfcontent type="application/msexcel" reset="yes"><cfoutput>#csvFile#</cfoutput>

    Correct answer
    January 30, 2012

    Thank you. I realized what the problem was, I needed to add the following

    <cfsetting enablecfoutputonly="Yes" showdebugoutput="no">

    THis solved the issue.  thanks.

    Inspiring
    January 30, 2012

    Please show the code that generates your csv file.