Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving CF generated Excel file 2

Status
Not open for further replies.

toyt78

Technical User
Apr 5, 2005
125
US
I have an Excel file that is generated from an Access 2000 database using Cold Fusion MX on a Windows 2000 server and it works great. I am now trying to copy this Excel file into another folder once a week where I will use the CFScheduler.

Both my copy attempts are not working and just show Cold Fusion code. The one where I tried ExcelCopy.xls shows an Excel spreadsheet with Cold Fusion variables and doesnt work.


If I try this it shows Cold Fusion variables.
Code:
<cflock name="myLock" type="EXCLUSIVE" timeout="30">
	<cffile action="COPY" source="C:\myserverDirectorypath\Excel.cfm" destination="C:\inforserverDirectoryPath\ExcelCopy.xls">
</cflock>

This didnt work either:
Code:
<cflock name="myLock" type="EXCLUSIVE" timeout="30">
	<cffile action="COPY" source="C:\myserverDirectorypath\Excel.cfm" destination="C:\inforserverDirectoryPath\ExcelCopy.cfm">

</cflock>



Please advise.
 
maybe im confused, but if you're doing a cffile copy from a .cfm page to a .xls page, it stands to reason you would see code in the .xls page- cffile is not going to parse the .cfm file first and then copy it's results- it's just going to simply copy the file.

it looks like Excel.cfm is used to generate ExcelCopy.xls which would make sense, you would need to run excel.cfm and copy it's output as an excel file to the other directory.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Northstar is right, you can't just copy a raw CFM file and change the file name and expect to see your dynamic data. The page must be "run" not just copied.

you may want to look into cfsavecontent.
and cffile action = "write"

the examples are kind of crappy

basic psudo code
Code:
<cfsavecontent variable = "myStuff">
  cf code to get your data out of the database
</cfsavecontent>
<cffile action = "write" file="C:\inforserverDirectoryPath\ExcelCopy.xls" output = "#myStuff#">

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Thanks, it now works.

I also created a page with the <cfschedule> tag to download this file once a week at 09:40 AM. I assume I have this correct?

Code:
<CFSCHEDULE action="UPDATE" interval="weekly" task="mytaskname" operation="HTTPRequest" startdate="8/30/05" starttime="9:40 AM" url="[URL unfurl="true"]http://theserverhere/directory/theExcelPage.cfm">[/URL]
 
do you not have access to the cf admin? it's easier to schedule a task that way, i only would use cfschedule in cases where i needed to allow end-users to create a scheduled task. at any rate, if you created a page with cfschedule on it, as long as you are aware that you would only need to run that page once to create the task, you should be ok.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top