什么叫系统的?就是普通的Grid控件呀。
授人以渔,不授人以鱼。
CREATE CURSOR TABA (JGID C(9),ZWDM C(1),行政职务 C(6),姓名 C(6)) INSERT INTO TABA VALUES ("140207000","1","理事长","姓名1") INSERT INTO TABA VALUES ("140207000","2","监事长","姓名2") INSERT INTO TABA VALUES ("140207000","3","主任","姓名3") INSERT INTO TABA VALUES ("140207000","4","副主任","姓名4") INSERT INTO TABA VALUES ("140207000","4","副主任","姓名5") INSERT INTO TABA VALUES ("140207000","4","副主任","姓名6") INSERT INTO TABA VALUES ("140207000","4","副主任","姓名7") INSERT INTO TABA VALUES ("140207000","4","副主任","姓名8") INSERT INTO TABA VALUES ("140206000","3","主任","姓名9") INSERT INTO TABA VALUES ("140206000","4","副主任","姓名10") INSERT INTO TABA VALUES ("140206000","4","副主任","姓名11") INSERT INTO TABA VALUES ("140201000","1","理事长","姓名12") INSERT INTO TABA VALUES ("140201000","4","副主任","姓名13") *------------------------------------------------------ *--- 生成[职数]数组 SELECT JGID,COUNT(*) AS 职数 FROM TABA GROUP BY JGID INTO ARRAY ATABA_1 *--- 生成[行政职务] 职数 临时表 SELECT JGID,ZWDM,行政职务,COUNT(*) AS 职数 FROM TABA GROUP BY JGID,ZWDM,行政职务 INTO CURSOR TABA_1 *--- 职位最多的人数 CALCULATE MAX(职数) TO ZSMAX *--- 生成[行政职务]数组 SELECT DISTINCT ZWDM,行政职务 FROM TABA INTO ARRAY ATABA_2 *--- 生成按[行政职务]排列 SELECT JGID,ZWDM,行政职务,CAST(FUN(JGID,行政职务) AS C(40)) AS 姓名 FROM TABA GROUP BY JGID,ZWDM,行政职务 INTO ARRAY ATABA_3 *--- 合计 SELECT SPACE(10) AS 合计,COUNT(*) FROM TABA UNION (SELECT 行政职务,COUNT(*) FROM TABA GROUP BY 行政职务) INTO ARRAY ATABA_4 *--- 生成查询临时表结构 CSTR="" FOR I=1 TO ALEN(ATABA_2,1) CSTR=CSTR+ALLTRIM(ATABA_2(I,2))+[ C(]+TRANSFORM(7*ZSMAX-1)+[)]+IIF(I<ALEN(ATABA_2,1),[,],[]) ENDFOR CREATE CURSOR TABB (JGID C(10),职数 N(4),&CSTR) *--- 添加数据 APPEND FROM ARRAY ATABA_1 SCAN FOR I=3 TO FCOUNT() FOR J=1 TO ALEN(ATABA_3,1) REPLACE (FIELD(I)) WITH ATABA_3(J,4) FOR ALLTRIM(JGID)==ALLTRIM(ATABA_3(J,1)) AND (FIELD(I))=ALLTRIM(ATABA_3(J,3)) ENDFOR ENDFOR ENDSCAN *--- 生成[合计]行 INSERT INTO TABB (JGID) VALUES ("合 计") FOR I=2 TO FCOUNT() REPLACE RECORD RECCOUNT() (FIELD(I)) WITH IIF(TYPE((FIELD(I)))="N",ATABA_4(I-1,2),TRANSFORM(ATABA_4(I-1,2))) ENDFOR SELECT * FROM TABB INTO ARRAY ATABA_6 *--- 调整临时数据表结构 LOCAL ATABA_5(FCOUNT()-2,1) FOR I=3 TO FCOUNT() SELECT MAX(LEN(ALLTRIM(EVALUATE(FIELD(I))))) FROM TABB INTO ARRAY ATABB ATABA_5(I-2,1)=ATABB ENDFOR CSTR="" FOR I=1 TO ALEN(ATABA_2,1) CSTR=CSTR+ALLTRIM(ATABA_2(I,2))+[ C(]+TRANSFORM(ATABA_5(I,1))+[)]+IIF(I<ALEN(ATABA_2,1),[,],[]) ENDFOR CREATE CURSOR TABC (JGID C(10),职数 N(4),&CSTR) APPEND FROM ARRAY ATABA_6 BROWSE RELEASE ALL LIKE ATABA* USE IN ("TABA_1") USE IN ("TABA") USE IN ("TABB") *--- 自定义函数 ---* FUNCTION FUN PARAMETER CJGID,CNAME CSTR="" SELECT TABA SCAN FOR ALLTRIM(JGID)==ALLTRIM(CJGID) AND ALLTRIM(行政职务)==ALLTRIM(CNAME) CSTR=CSTR+ALLTRIM(姓名)+"-" ENDSCAN RETURN LEFT(CSTR,LEN(CSTR)-1) ENDFUNC