creating .doc files in Coldfusion

376 views
Skip to first unread message

<cfgroupie>

unread,
Jul 4, 2006, 1:56:47 AM7/4/06
to cfaussie
Hey guys,

I have a need to create word documents on the file based on data. Has
anyone done this and if so can they point me in the right direction. I
had a look at lots of examples on the web using COM objects but they
all seem to be having issues.

Jeremy

Andrew Scott

unread,
Jul 4, 2006, 2:02:19 AM7/4/06
to cfau...@googlegroups.com

Hmm,

Is this Coldfusion MX7+ then look at cfdocument. If it is not then look at
JasperReports, this is what is used by Coldfusion MX7.0 to deliver the
reporting solutions offer by coldfusion.

Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 8676 4223
Mobile: 0404 998 273

Rod Higgins

unread,
Jul 4, 2006, 2:03:42 AM7/4/06
to cfau...@googlegroups.com
I've used POI successfully before. The other option is too create the word
document save it as html then use CF to create the same html and save as a
.doc file. If the application's users have Office 2003, xml might be an
option as well.

All options work it just depends on your needs.

----- Original Message -----
From: "<cfgroupie>" <jer...@circlethree.com>
To: "cfaussie" <cfau...@googlegroups.com>
Sent: Tuesday, July 04, 2006 3:56 PM
Subject: [cfaussie] creating .doc files in Coldfusion


>

Mike Kear

unread,
Jul 4, 2006, 3:06:22 AM7/4/06
to cfau...@googlegroups.com
You might also like to consider making rtf format files instead.
they're readable by word and more portable, and there are a host of
tutorials on the net about how to do it. (Thanks again Kym Kovan for
the tip on that )

You dont have to use CFDocument so you can do it with any version of
CF. I'm not at my own office right now or i'd dig out the link to
the tutorial for you, but you should be able to find it by googling
ColdFusion + RTF

Cheers
Mike Kear
Windsor, NSW, Australia
Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month

Mark Ireland

unread,
Jul 4, 2006, 7:12:55 PM7/4/06
to cfau...@googlegroups.com

There is always the BLOB.


From:  "Rod Higgins" <rod.h...@exemail.com.au>
Reply-To:  cfau...@googlegroups.com
To:  <cfau...@googlegroups.com>
Subject:  [cfaussie] Re: creating .doc files in Coldfusion
Date:  Tue, 4 Jul 2006 16:03:42 +1000

Patrick Branley

unread,
Jul 4, 2006, 7:31:44 PM7/4/06
to cfau...@googlegroups.com
The other option that works is just to serve up HTML and set the content type to msword/document and set the extension to *.doc in the content-disposition header.
eg.
<cfheader name="Content-Type" value="application/msword" >
<cfheader name="Content-Dispostion" value="attachment; filename=myfile.doc" ><cfoutput>#htmlContent#</cfoutput>

Im pretty sure any version of word past about 97 will open up html files.

You can get the formatting you need by creating the doc in word then saving it as HTML. then just output all the embedded CSS that word puts into the document. Its bascially the same technique as RTF but gives you a bit nice source code to work with to apply formatting to.

hth

Pat

ps. it works with excel documents too.

<cfgroupie>

unread,
Jul 5, 2006, 2:18:22 AM7/5/06
to cfaussie
Hey guys,

Yeah I agree with most of what you guys have said....Turns out they
want to use com objects....*sigh* no one ever listens to me.

Thanks everyone

Jeremy

Andrew Scott

unread,
Jul 5, 2006, 2:33:42 AM7/5/06
to cfau...@googlegroups.com
Why com, why not java... Jaspwer Reports is more flexible than com
objects:-)



Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 8676 4223
Mobile: 0404 998 273

-----Original Message-----
From: cfau...@googlegroups.com [mailto:cfau...@googlegroups.com] On Behalf
Of <cfgroupie>

Sent: Wednesday, 5 July 2006 4:18 PM
To: cfaussie
Subject: [cfaussie] Re: creating .doc files in Coldfusion

Mark Ireland

unread,
Jul 5, 2006, 7:06:23 PM7/5/06
to cfau...@googlegroups.com

Yes, this works well. You really only need the BLOB option if there is more than ascii in the file (eg pictures).

WIth Oracle you dont even need the cf admin option turned on.


From:  "Patrick Branley" <pbra...@gmail.com>

Reply-To:  cfau...@googlegroups.com
To:  cfau...@googlegroups.com
Subject:  [cfaussie] Re: creating .doc files in Coldfusion
Date:  Wed, 5 Jul 2006 09:31:44 +1000


Find lost friends & family online! Search for free.

Patrick Branley

unread,
Jul 5, 2006, 7:26:25 PM7/5/06
to cfau...@googlegroups.com
I remember looking into the use of the COM object approach in the past and somehow i think it breaks liscencing rules ?

at the very least it requires a copy of office installed on th server.

Pat

Nathan Drury

unread,
Jul 6, 2006, 7:03:28 PM7/6/06
to cfaussie
Using COM does require a licensed copy of Office on the server.
However, even Microsoft doesn't recommend using Office on the server!
http://support.microsoft.com/kb/257757/en/

In a past life I used COM extensively with CF5 and it was very
unreliable and quite slow. I can't imagine it would be any better
using CFMX given its now Java rather than C++.

I've used POI for generating and reading Excel files. It's relatively
simple and it works a treat (just make sure you use javaCast for int
values). However I have not used it for generating Word docs so can't
comment in that regards. If it were me, I'd be trying POI or Jasper
(Jasper uses POI for generating its Excel and Word docs).

Reply all
Reply to author
Forward
0 new messages