excel - CFspreadsheet looping -
excel - CFspreadsheet looping -
i have question regarding cfspreadsheet....so i'm using cfspreadshseet create excel spreadsheets reporting purposes. page allows user select whatever columns database include in report. here example:
the spreadsheet this:
first name---last name---organization---address---city---state---zip---concern
joe smith sample 12 main denver co 80513 concerns go here
my question this, if joe has more 1 concern multiple rows joe's info...is there way can loop concerns , have 1 row joe?
thanks,
steve
using "group" feature of cfoutput fine task. throw out possibility, generate list within database query.
for example, mysql has group_concat function. not know construction of tables, have 2 tables user , userconcern, utilize group_concat concatenate "concern" values single string:
sqlfiddle
select u.userid , u.firstname , ... other columns , group_concat( uc.concern ) concernlist usertable u inner bring together userconcern uc on uc.userid = u.userid grouping u.userid , u.firstname , ... other columns for sql server, standard trick utilize xml path:
sqlfiddle
select u.userid , u.firstname , ... other columns , stuff( ( select ',' + uc.concern userconcern uc uc.userid = u.userid order uc.concern xml path('') ) , 1, 1, '' ) concernlist usertable u grouping u.userid , u.firstname , ... other columns then generate spreadsheet usual.
excel coldfusion coldfusion-10 cfspreadsheet
Comments
Post a Comment