Skip to main content
April 19, 2007
Question

cfcontent/cfheader with word 2007

  • April 19, 2007
  • 9 replies
  • 3320 views
Anyways to make this output into a 2007 word doc (I tried calling the file Membership List.docx and it corrupted it).

<CFHEADER NAME="content-disposition" VALUE="attachment; filename=Membership List.doc">
<cfcontent type="application/msword">
    This topic has been closed for replies.

    9 replies

    June 2, 2010

    If you are trying to read an existing file that is word 2007 (docx) this works:

    <CFHEADER NAME="content-disposition" VALUE="attachment; filename=Membership List.docx">
    <cfcontent type="application/x-zip-compressed" file="c:\Membership List.docx">

    Inspiring
    April 27, 2007
    Wow, that looks... uh... messy. Good find scooter5791.
    Inspiring
    April 26, 2007
    You still should be able to generate the document as the usual .doc file (which Word will still be able to recognize). Otherwise, you can try one of the following:

    1) Do a search on the CF sites to see if anyone has written a CFX tag for creating a .docx file
    2) check out the Java Jakarta POI project. They have a java object that allows you to read from/write to .doc files (though its still in development and I'm not sure they've tacked .docx yet)
    3) Try to find some documentation on the .docx file format and recreate it in CF.

    Seems like most of those are more effort than its really worth. I'd say if you can find a CFX tag out there (might be tricky due to .docx being fairly new), then your best bet is to go with .doc
    Inspiring
    April 26, 2007
    BKBK is correct: a Word 2007 .docx file is a zip archive. This article may help:

    http://msdn.microsoft.com/msdnmag/issues/06/11/basicinstincts/default.aspx
    April 26, 2007
    Maybe that's it Michael. Maybe because it is a dynamic document (there is no path, no ready-made docx document, just a dynamic member list bkbk) with html, maybe the 2007 word can only deal with style sheets? I'll do a test with just text and see if that gets corrupted. update: i stripped out the html and it still gets corrupted. So I guess the fact that it saves it as html must be what is corrupting it like you said. now what..
    BKBK
    Community Expert
    Community Expert
    April 26, 2007
    Indeed, Michael. Docx is not only new MIME, it is more zip than doc technology.

    Inspiring
    April 25, 2007
    I wonder if the word 2007 .docx format can accept HTML formatting. After all, for previous versions of word, you're creating an html file with a .doc extension that Word knows how to translate into a wordprocessing document. Has anyone had any success doing the same for .docx?
    BKBK
    Community Expert
    Community Expert
    April 25, 2007
    I was thinking you're using some simple text just to test. It now sounds like you have a full-blown .docx file that you want the client to download. If that be so, include the path of the file. For example,

    <cfcontent type="application/unknown" file="c:\docx\testFile.docx">
    or
    <cfcontent type="application/octet-stream" file="c:\docx\testFile.docx">

    BKBK
    Community Expert
    Community Expert
    April 21, 2007
    same code, however, with .docx and type="application/unknown" or type="application/octet-stream"

    April 25, 2007
    HI there, I tried both of your suggestions and the content gets corrupted when I try to open it with word 2007:
    i.e.
    <CFHEADER NAME="content-disposition" VALUE="attachment; filename=reportresults.docx">
    <cfcontent type="application/unknown">
    BKBK
    Community Expert
    Community Expert
    April 20, 2007
    And when you place this at the top of the page, with no space in the file name?

    <CFHEADER NAME="content-disposition" VALUE="attachment; filename=MembershipList.doc">
    <cfcontent type="application/msword">


    April 20, 2007
    woops I think you misundersttood my question; I have no problem exporting it to word (.doc); what I want to do is export as .docx (word 2007)