Create Files on the Fly in ColdFusion
page 4 of 6
by Sarita Mishra
Feedback
Average Rating: 
Views (Total / Last 10 Days): 33655/ 39

Creating MS Word file

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>

View Entire Article

User Comments

Title: great   
Name: Sandy
Date: 2006-11-02 6:33:11 AM
Comment:
Great job.. keep moving ahead
Title: Kar   
Name: Chandrakanta
Date: 2006-11-01 2:56:09 AM
Comment:
It is very nice and can also helpful for the new developers. Come across creating different file formats at the time of requirement.
Title: Great Job   
Name: pd
Date: 2006-11-01 2:41:58 AM
Comment:
Keep it up.
Title: Nice Article   
Name: Tom Anderson
Date: 2006-10-31 1:46:13 AM
Comment:
Very Nice and informative article for people working on ColdFusion.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-24 9:07:54 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search