Has anyone encountered problems using <cfspreadsheet action='write'> inside
a function?

Take a look at the code below:
==========================
    <cfset myQuery = queryNew("ID,Name")>
    <cfset queryAddRow(myQuery) />
    <cfset querySetCell(myQuery,"ID",1) />
    <cfset querySetCell(myQuery,"Name","Lucy")>
    <cfset queryAddRow(myQuery) />
    <cfset querySetCell(myQuery,"ID",2) />
    <cfset querySetCell(myQuery,"Name","Desi")>
    <cfdump var="#myQuery#">
    <cfset path = "C:\lucy.xlsx" />
    <cfdump var="#path#">
    <cffunction name="build" access="public" returntype="any"
output="false">
        <cfargument name="myQuery" type="query" required="true" />
        <cfargument name="path" type="string" required="true" />
        <cfset var ss = spreadsheetNew("Desilu",true) />
        <cfset spreadSheetAddRow(ss,"ID,Character Name")>
        <cfloop query="arguments.myQuery">
            <cfset spreadsheetsetCellValue(ss,arguments.myQuery.ID,
arguments.myQuery.currentRow+1,1) />
            <cfset spreadsheetsetCellValue(ss,arguments.myQuery.Name,
arguments.myQuery.currentRow+1,2) />
        </cfloop>
        <!---<cfspreadsheet action="write" filename="#arguments.path#"
name="ss" overwrite="true" sheetname="Fred" />--->
        <cfreturn ss>
    </cffunction>
    <cfset desilu = build(myQuery,path) />
    <cfdump var="#desilu#">
    <cfspreadsheet action="write" filename="#path#" name="desilu"
overwrite="true" sheetname="Desilu" />
===================
Note the commented-out line within the function, writing the spreadsheet
file. If it remains commented, the spreadsheet is written correctly by the
final action in the code.

However, if the comments are removed, an error occurs during the function:
'Specified variable ss is not-defined or invalid.'

Yet obviously, the variable is defined. And when it is returned outside the
function, it is valid for writing a spreadsheet in the second
<cfspreadsheet> tag.

The error only occurs when I apply the 'write' action within a function. And
seeing as how I really want all of this to take place within a CFC, it needs
to happen *inside* a function.

Can someone just confirm that I'm not crazy, and perhaps give me some
advice? Googling hasn't help. And there don't seem to be any
spreadsheet-related bugs filed in the Adobe bugbase.

-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331391
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to