Copy link to clipboard
Copied
I have this code for a generic template:
<cfset fileName="c:\temp\wordTmpDoc"&randRange(1,100000)&".htm"> |
<cfif fileExists(fileName)><cffile action="delete" file="#fileName#"></cfif>
<cfsavecontent variable="htm"><CFINCLUDE template="#incl#.cfm"></cfsavecontent>
<cffile action="write" file="#fileName#" output="#htm#">
<cfcontent file="#fileName#" deletefile="no" type="application/msword">
Note the CFINCLUDE. I also have another template that goes through generating the html in a cfsavecontent and at the bottom it has essentially the same code but uses the HTML generated on the page as the content for the document. The above generic version brings up MS Word but the content is the HTML code, while the page that has local cfsavecontent wrapping the HTML, the document displays properly.
Copy link to clipboard
Copied
OK, now I'm really confused. I put a cfdump on the generic template, removed it, and moved a closing </div> to the next line on the cfinclude file and now....... it produces a proper Word doc instead of HTML! Ghost in the machine. I did not change anything important one either file, and I lost a LOT of time trying to debug the issue. If anyone else encounters this problem and can explain the cause and the solution, please feel free to contribute.