#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    38
    Rep Power
    6

    Error Generating Excel file with ColdFusion7


    I am trying to generate an Excel file using CF MX7 and it seems to work fine when I test on my own machine (which acts as my testing server) but generates an error on the production server: Unable to create temporary file
    Below is the code:
    Code:
    <cfsavecontent variable="strExcelData">
     
    	<style type="text/css">
    		table tr td{font-family:"Times New Roman", Times, serif; padding:0 1em 1em 1em; text-align:center;}
    		.blankCell{background-color:#6E8;}
    		.columnHeader{background-color:#6E8; text-align:center; font-weight:bold;}
    		.commentsColumn{background-color:#6E8; width:200px; text-align:center; font-weight:bold;}
    	</style>
    
    	....Various cfqueries here...
    	
    	<!--- Bunch of cfparam Definitions Here --->
    	<cfparam name="Var.myVar1" default="">
    	<cfparam name="Var.myVar2" default="">
    	....<More cfparam definitions>....
    	
    	<table>
    		<tr><td colspan="4">Patient Flowsheet</td></tr>
    		
    		<cfoutput>
    			<tr>
    				.....................................
    				....Dataset From Queries goes here...
    				.....................................
    			</tr>
    		</cfoutput>
    	</table>
    </cfsavecontent>
    
    <cfheader name="Content-Disposition" value="filename=Patient_Flowsheet.xls" />
     
    <!--- Get the temp file for streaming. --->
    <cfset strFilePath = GetTempFile(GetTempDirectory(), "excel_") />
    
    <!--- Write the excel data to the file. --->
    <cffile action="WRITE" file="#strFilePath#" output="#strExcelData.Trim()#" />
    
    <cfcontent type="application/msexcel" variable="#ToBinary( ToBase64( strExcelData.Trim() ) )#" />
    Could there be settings on the production server (that I do not have access to) that could explain why it works on the local machine but not on the remote one? If yes, what is the workaround?
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    Looks like the server does not allow you to write to temp directory?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    38
    Rep Power
    6
    Originally Posted by kiteless
    Looks like the server does not allow you to write to temp directory?
    So is there another way to do this?
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    You could try writing to some other directory (perhaps one within your own directory structure). But if the host has disabled writing to the file system completely, then your only options are to switch hosts or attempt to create the content and push it with cfcontent without saving it to disk.

    Looking at your code, you could try just removing the GetTempFile() and cffile lines, since you're pushing the content straight into cfcontent as a variable.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    38
    Rep Power
    6
    Originally Posted by kiteless
    You could try writing to some other directory (perhaps one within your own directory structure). But if the host has disabled writing to the file system completely, then your only options are to switch hosts or attempt to create the content and push it with cfcontent without saving it to disk.

    Looking at your code, you could try just removing the GetTempFile() and cffile lines, since you're pushing the content straight into cfcontent as a variable.
    Awesome! That worked beautifully.

IMN logo majestic logo threadwatch logo seochat tools logo