Skip to main content
Inspiring
May 7, 2008
Question

access output question

  • May 7, 2008
  • 3 replies
  • 467 views
Hi,

I'm new at CF. I have an access database that is taking in form data. That
part I got working fine, but what I'd like to know is there a way to use cf
(6.1) to extract the data and format it into either a word document, or
excel spreadsheet, then either email it and/or dump it into a directory on
the server?

Thanks


This topic has been closed for replies.

3 replies

Inspiring
May 16, 2008
Thanks,

I'll try these suggestions

"Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
news:g01i3j$1hu$1@forums.macromedia.com...
> To extract the data, use <cfquery>. That's the easy part.
>
> Regarding excel, see if a delimited text file is sufficient. Whoever
> receives
> it can open it with excel and use file-save as to rename it, if that's
> what
> they want to do. Use <cffile> to create text files and
> <cfmail>/<cfmailpamam>
> to send them.
>


Inspiring
May 9, 2008
To extract the data, use <cfquery>. That's the easy part.

Regarding excel, see if a delimited text file is sufficient. Whoever receives it can open it with excel and use file-save as to rename it, if that's what they want to do. Use <cffile> to create text files and <cfmail>/<cfmailpamam> to send them.
May 8, 2008
I did this a few years back when we had 6.1. It may have not been the best way but it worked. You first need to create a template document. Create it in MS Word or whatever but it needs to be saved as a .rtf file instead of a .doc (6.1 couldn't write to a .doc file or something but it didn't matter because all you have to do is change the extension after you're finished.) Format the document a required then everywhere you want to insert data from Access add a unique variable in the form of %variableName%.

Next in you cfm file you have to query the data. Then using cffile read the template file into memory, something like <cffile
action="Read"
file="#TemplatePath#"
variable="RTF">
Now replace the placeholder variables you created in the template with the data, like so:
<cfset RTF = Replace(RTF, "%variableName%", queryname.datacolumn)>

Finally, I suggested a new default filename for document with
<cfheader name="Content-Disposition" value="filename=Letter.doc">

and then set the content-type so Word is invoked
<cfcontent type="application/msword"><cfoutput>#RTF#</cfoutput>

This of course opened Word on the Client's computer and wrote all the information to the document which would be saved to wherever they wanted as letter.doc unless they specified otherwise. If you want it to write to a folder on the server just skip the last two lines above and use cffile again to write the RTF variable back to a file younameit.doc to whatever path you want. You can then attach it to an email or have a page link displayed on screen.

It's been a while since I wrote this but I quite sure that how I did it. Hope it helps.