coldfusion - QueryNew() Data Types in CF9 -


i have taken on system on production server running cf9.0.1 , cannot find copy of in developer's edition, running cf10.

i exporting data database excel. because data comes multiple datasources, results manually entered query used output excel. 1 of first problems solve that, because excel automatically types data, wierd things happening trailing zeros being dropped, numbers turned dates, etc. after lot of research, tried specifying datatypes of data going query "varchar" excel read text. this, replaced original querynew following line of code.

dataquery = querynew("row_number,function,nomenclature,hw,crit,load,sw,media,svd,bds,ecp,install,notes", "varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar, varchar"); 

that worked great on cf10. then, got posted production cf9 , didn't solve anything. excel still not receiving data text type , autoformatting it. so, tried following instead.

dataquery = querynew("row_number,function,nomenclature,hw,crit,load,sw,media,svd,bds,ecp,install,notes", "cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar, cf_sql_varchar"); 

again, didn't work on cf9, great on cf10.

is there cf9 missing making not work? wonderful!

sorry not doing sooner. sample code shows problem i'm having. exports excel on cf10, has problems on cf9.

<cfscript>     dataquery = querynew("row_number,function,nomenclature,hw,crit,load,sw,media,svd,bds,ecp,install,notes", "varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar");       //row #1     newrow = queryaddrow(dataquery);     querysetcell(dataquery,"row_number","1");     querysetcell(dataquery,"function","function 1");     querysetcell(dataquery,"nomenclature","nomen 1");     querysetcell(dataquery,"hw","185019-001"); //sometimes axports exponent     querysetcell(dataquery,"crit","2");     querysetcell(dataquery,"load","load 12b rl");     querysetcell(dataquery,"sw","0.0620"); //this 1 trailing 0 left off     querysetcell(dataquery,"media","media 1");     querysetcell(dataquery,"svd","6529-02"); // turned date     querysetcell(dataquery,"bds","bds 1");     querysetcell(dataquery,"ecp","ecp1");     querysetcell(dataquery,"install","install 1");     querysetcell(dataquery,"notes","note1");      //row #2     newrow = queryaddrow(dataquery);     querysetcell(dataquery,"row_number","2");     querysetcell(dataquery,"function","function 2");     querysetcell(dataquery,"nomenclature","nomen 2");     querysetcell(dataquery,"hw","185019-005"); //sometimes axports exponent     querysetcell(dataquery,"crit","2");     querysetcell(dataquery,"load","load 12b rl");     querysetcell(dataquery,"sw","0.06200"); //this 1 trailing 0 left off     querysetcell(dataquery,"media","media 2");     querysetcell(dataquery,"svd","6529-03"); // turned date     querysetcell(dataquery,"bds","bds 2");     querysetcell(dataquery,"ecp","ecp 2");     querysetcell(dataquery,"install","install 2");     querysetcell(dataquery,"notes","note2");      sheet= spreadsheetnew("new", "true");      spreadsheetaddrows(sheet,dataquery);      </cfscript> <cfspreadsheet action="write" filename="c:/cf9exceltest.xlsx"  name="sheet" overwrite="true" >  

thank help.

try formatting column/cells text first. see format example in docs, under enhancement in coldfusion 9.0.1. ie

// format individual cell  ... spreadsheetformatcell(sheet, {dataformat="@"}, rownum, columnnum);  // format columns 4 , 7 spreadsheetformatcolumns(sheet, {dataformat="@"}, "4,7") 

unfortunately of spreadsheet functions in cf9.x bit quirky, not sure if work in combination spreadsheetaddrows. if not, may need resort loop , within format , assign cell values individually:

   ...    spreadsheetformatcell(sheet, {dataformat="@"}, rownum, columnnum);     spreadsheetsetcellvalue(sheet, "some value", rownum, columnnum);    ... 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -