在Coldfusion中附加文件

时间:2014-06-05 19:04:44

标签: coldfusion coldfusion-9

我正在获取Word RTF文件,然后替换其中的数据,然后将其写入特定文件夹并将requestID附加到文件名。那部分效果很好。但是,我的客户还希望能够打印在多个记录中生成的每个word文档。

为此,我正在读取相同的RTF文件,替换其中的数据,然后写入我试图在循环中附加的单独文件,但它不起作用。我只收到一条查询记录。

        <cfloop query="checklistData">

        <cffile action="read" file="#request.filePath#\_reports\fileChecklist.rtf" variable="rtf">

        <cfset rtf = Replace(rtf,"%PROGRAM%",#rqst_activity#)>
        <cfset rtf = Replace(rtf,"%DLA%",#DLA#)>
        <cfset rtf = Replace(rtf,"%SPS%",#SPS#)>
        <cfset rtf = Replace(rtf,"%ECAT%",#ECAT#)>
        <cfset rtf = Replace(rtf,"%MILSTRIP%",#MILSTRIP#)>
        <cfset rtf = Replace(rtf,"%TDPNUM%",#tdp_nbr#)>
        <cfset rtf = Replace(rtf,"%DTRQST%",#DateFormat(dt_tdp_rcvd,'M/DD/YYYY')#)>
        <cfset rtf = Replace(rtf,"%DTCMPT%",#DateFormat(dt_tdp_cmplt,'M/DD/YYYY')#)>
        <cfset rtf = Replace(rtf,"%DTDEL%",#DateFormat(rqsted_delivery_dt,'M/DD/YYYY')#)>
        <cfset rtf = Replace(rtf,"%UIC%",#DoDAAC#)>
        <cfset rtf = Replace(rtf,"%COMMAND%",#COMMAND#)>
        <cfset rtf = Replace(rtf,"%DTPRINT%",#DateFormat(NOW(),'M/DD/YYYY')#)>
        <cfset rtf = Replace(rtf,"%NSN%",#nsn_id_rqsted#)>
        <cfset rtf = Replace(rtf,"%NOMEN%",#nsn_nomenclature#)>


        <cfset directoryCheck = "#request.filePath#\requests\documents\#checklistData.id_rqst#">

        <cfif directoryExists(directoryCheck)>
            <cffile action="write" file="#request.filePath#\requests\documents\#checklistData.id_rqst#\fileChecklist_#checklistData.id_rqst#.doc" output="#rtf#" nameconflict="overwrite">
        <cfelse>
            <cfdirectory action="create" directory="#directoryCheck#">
            <cffile action="write" file="#request.filePath#\requests\documents\#checklistData.id_rqst#\fileChecklist_#checklistData.id_rqst#.doc" output="#rtf#" nameconflict="overwrite">
        </cfif>

        <cffile action="append" file="#request.filePath#\requests\documents\fileChecklistGroup_#ARGUMENTS.groupID#.rtf" output="#rtf#">

    </cfloop>

    <cfif NOT LEN('checklistData.groupID')>
        <cfheader name="content-disposition" value="filename=#request.filePath#\requests\documents\#requestID#\fileChecklist_#requestID#.doc" />  
        <cfcontent type="application/msword" file="#request.filePath#\requests\documents\#requestID#\fileChecklist_#requestID#.doc">
    <cfelse>
        <cfheader name="content-disposition" value="filename=#request.filePath#\requests\documents\fileChecklistGroup_#groupID#.rtf" />  
        <cfcontent type="application/msword" file="#request.filePath#\requests\documents\fileChecklistGroup_#groupID#.rtf">
    </cfif>

    <cfabort>

然后我要求在最后打开文件。提前感谢您的帮助!

0 个答案:

没有答案