• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

exporting data to Word with Coldfusion

New Here ,
Aug 25, 2010 Aug 25, 2010

Copy link to clipboard

Copied

Saw the link at

http://www.irt.org/articles/js154/index.htm which explains how to do it.

But, my need is a bit more than what is shown.

I have to run a query and based on results of it decide what should be a row title, then display its value. Something like

<cfquery name="getDepartments" datasource="#Application.ds#">
                    SELECT *
                    FROM departments
                    WHERE deptID = '#form_data.deptID#'
                </cfquery>

then

<table width="100%" border="1" rules="all" cellpadding="5px" cellspacing="0px" style="width:100%; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
                            <tr>
                                <td style="font-family:Arial; font-size:12px;"><b>

<cfif getDepartments.DEPT_TYPE is 'AP'>
                                        Corporate
                                    <cfelse>
                                        Retail
                                    </cfif>
                                    :</b>
                                    <br>

This does not work using the method shown at the link http://www.irt.org/articles/js154/index.htm

How can I achieve what I want?

Any advice would be welcome.

TOPICS
Reporting

Views

4.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Aug 26, 2010 Aug 26, 2010

Well, the two formats are totally different. I do not think you can mix the two. So either you are trying to create an rtf file or an html file.

Most versions of MS Word are capable of interpreting/displaying html. So unless you specifically need an rtf file, it is easier to just generate plain html. Then use cfheader and cfcontent to indicate the document should be opened with MS Word. There is an example for Excel at the bottom of this page. But the same concept applies to Word files. Just use

...

Votes

Translate

Translate
Valorous Hero ,
Aug 25, 2010 Aug 25, 2010

Copy link to clipboard

Copied

This does not work

What do you mean by "does not work"?

What results are you expecting, and how do the actual results differ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2010 Aug 26, 2010

Copy link to clipboard

Copied

Thanks for the response. I should have been more clear in my first post.

The parsing fails because of the HTML table formatting which I need. Because the method shown at http://www.irt.org/articles/js154/index.htm is shown for values already present, not something which is done dynamically using that results with table formatting is done. In other words, the link shows something like Personnel name #PersonnelName#

I need something like if personnel exists then show a table row with cellpadding/cell spacing, display personnel name in a particular font size and name.

Results I am expecting are if a record exists in my table, I should be able to display it with HTML table formatting. This is not happening as the mixture of the code used for RTF and HTML table is throwing off the parsing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 26, 2010 Aug 26, 2010

Copy link to clipboard

Copied

Well, the two formats are totally different. I do not think you can mix the two. So either you are trying to create an rtf file or an html file.

Most versions of MS Word are capable of interpreting/displaying html. So unless you specifically need an rtf file, it is easier to just generate plain html. Then use cfheader and cfcontent to indicate the document should be opened with MS Word. There is an example for Excel at the bottom of this page. But the same concept applies to Word files. Just use the correct mime type and file name.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_c_11.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2010 Aug 26, 2010

Copy link to clipboard

Copied

Thanks for the response.

I am presently generating a PDF file and using HTML formatting to format a table inside it so that the generated contents can be placed properly inside a table. I have something like

Row 1

Row 1 Contents

Row 2

Row 2 Contents

What I want now is the same contents to be placed neatly inside a table in a RTF/Word document. I know RTF document can be created by Coldfusion version 8. Can I add a table inside the RTF document so that my content is displayed properly as above?

Need for RTF is so that it can be saved later as MS-Word document, comments can be added to it and so on.

Can that be done or is there a better way to do what I want?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 27, 2010 Aug 27, 2010

Copy link to clipboard

Copied

I am presently generating a PDF file and using HTML formatting ....

As I mentioned before, most versions of MS Word can interpret html.  So theoretically you could just use the same html, but add cfheader and cfcontent to trick the browser into thinking it is a Word document. Be sure to give it a *.doc extension.  MS Word should then treat the file as if it really were a regular Word document.  That is probably the simplest option.  (See the link in my previous response for an example.)

I know RTF document can be created by Coldfusion version 8. 

Technically you can construct an RTF file in any version.  As long as you understand the rtf specifications and the nitty-gritty details of the format.  That is what they are doing in the article, constructing one manually.

Can I add a table inside the RTF document so that my content is displayed properly as above?

Not a literal one, no.  Rtf and html are totally different and not compatible. If you want to create something different than what is shown in the article, you will have read up on the specs and find what syntax and character sequences to use.

http://msdn.microsoft.com/en-us/library/aa140277%28office.10%29.aspx

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2010 Aug 27, 2010

Copy link to clipboard

Copied

As I mentioned before, most versions of MS Word can interpret html.  So theoretically you could just use the same html, but add cfheader and cfcontent to trick the browser into thinking it is a Word document. Be sure to give it a *.doc extension.  MS Word should then treat the file as if it really were a regular Word document.  That is probably the simplest option.  (See the link in my previous response for an example.)

I will try doing that and see how it works out. Thanks for your suggestions and time. I have marked as your answer as helpful for your advice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 30, 2021 Sep 30, 2021

Copy link to clipboard

Copied

I am having similar issue - the link does not exists anymore . Could you please help .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2021 Sep 30, 2021

Copy link to clipboard

Copied

LATEST

@rekhas44174972 , If I were you I would create a new thread of my own, explaining in detail what I need. It is counter-productive to piggy-back on this thread. It is 11 years old, which is ancient in software terms. There have been many developments in ColdFusion since then.

 

In any case, if you stll want to see the irt.org page, search for the link on https://web.archive.org/. There, I found https://web.archive.org/web/20101123230304/http://www.irt.org/articles/js154/index.htm 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation