Steps
1) The change in the type of the file to be created in
CFCONTENT TYPE tag will solve this problem. Here it is msword type.
<CFHEADER NAME="Content-Disposition" VALUE="INLINE; FILENAME=filename.doc">
<CFCONTENT TYPE="application/msword" FILE="c:\temp\Cable.doc" DELETEFILE="yes">
Deletefile=”yes” will delete the file from the directory
after sending it to the client. If the user wants to be prompted with an
option to save the file or open it in the browser then the value="inline
will solve this. You can add all types of style setting which generally we do
in html.
Listing 5
<CFHEADER NAME="Content-Disposition" VALUE="INLINE;
FILENAME=test.doc">
<CFCONTENT TYPE="application/msword">
<CFOUTPUT>
<html>
<head>
<style type='text/css'>
p,td,ul,li {font-family: arial; helvetica; font-size: 12px}
h1 {font-family: arial; helvetica; font-size: 16px;}
</style>
</head>
<body>
<h1><font color="blue">This is an example of creating .doc files
from coldfusion.</font></h1>
<p>
<font style="Times New Roman">
This text is only meant for the purpose of
user creating .doc files from within coldfusion .cfm page.
</font>
</p>
</body>
</html>
</CFOUTPUT>