Skip to main content
Participating Frequently
April 24, 2012
Answered

Variable SRUCTNEW is undefined?!?

  • April 24, 2012
  • 2 replies
  • 1814 views

Hello, we recently upgraded to CF9.  One of the new features I want to play with is CFSPREADSHEET.

In working with the sample code I have found (here and elsewhere), most work fine.  But certain functions return a "Variable XXXX is undefined" error.

I am pretty sure this may be an install issue or a settings issue, but I can't find any resource on the web.  Here is a basic code snipet that simply errors out on the STRUCNEW line:

<cfscript>
    ///Set the file name
    theFile="#BaseRoot#files\FailureReportingAudit.xls";

    //Create a new Excel spreadsheet object and add test data.
    theSheet = SpreadsheetNew("CourseData");
   SpreadsheetAddRow(theSheet,"test, test1",1);

    // Define a format for the column.
    format1=SructNew() ;
    format1.font="Courier";
    format1.fontsize="10";
    format1.color="dark_blue;";
    format1.italic="true";
    format1.bold="true";
    format1.alignment="left";
    SpreadsheetFormatCellRange(theSheet,format1, 3,4,30,10);
</cfscript>

You can see the error for itself at: https://www.calcerts.com/_WTF_cfscript.cfm

If I comment out the code starting at StructNew all the way to the end of the cfscript, I receive no error and the XLS file is created, no problem.  But when I try and create a structure so I can format it I get an error.

Another interesting note, if I try to do the "SpreadsheetFormatCellRange" function manually (no format1 structure), I get a "Variable SPREADSHEETFORMATCELLRANGE is undefined"

So basically some (not all or even most) functions are not "defined"....

This topic has been closed for replies.
Correct answer -__cfSearching__-

Any idea why that function is not defined?  Did I not spell that one correctly?

It is spelled correctly but the documentation says it was added in 9.0.1. Perhaps you are running 9.0.0?

2 replies

Inspiring
April 24, 2012

Change sructnew() to sTructnew().

Participating Frequently
April 24, 2012

Thanks Dan,

OMG, I can't beleive I simply mispelled the word.....

Anyways, shame on Adobe for having sample script with typos, shame on me for not noticing it.

HOWEVER

that does not resolve the entire issue.  JMF provided a workaround for that error.  But for some reason

SpreadsheetFormatCellRange(theSheet,format1, 3,4,30,10);

is stopping at "SpreadsheetFormatCellRange"

Any idea why that function is not defined?  Did I not spell that one correctly?

Participating Frequently
April 24, 2012

I don't know.  Does the sheet have to have the rows populated for SpreadsheetFormatCellRange() to work?  Only one row has been added [with SpreadsheetAddRow()], but the range defines 30 rows.  I have no idea if that matters.

Participating Frequently
April 24, 2012

If you're using CF9, try the simpler syntax:

format1={};

Participating Frequently
April 24, 2012

Thanks JMF,

Nice workaround for the StructNew function, but now I am getting that "Variable SPREADSHEETFORMATCELLRANGE is undefined." error.