求解:快速行合计
如何通过自定义函数实现表中不固定字段的行合计?先谢谢了
* 测试表 CREATE CURSOR T (BH C(4),B1 N(4),B2 N(4),B3 N(4),B4 N(4)) INSERT INTO T VALUES ([0001],1200,1000,800,600) INSERT INTO T VALUES ([0002],1100,900,700,500) INSERT INTO T VALUES ([0003],1900,1700,1500,1300) SELECT *,000000 XJ FROM T INTO CURSOR TEMP READWRITE LCSTR=[] FOR I=2 TO FCOUNT()-1 LCSTR=LCSTR+FIELD(I)+IIF(I<FCOUNT()-1,[+],[]) ENDFOR * 行小计 REPLACE ALL XJ WITH &LCSTR INSERT INTO TEMP ((FIELD(1))) VALUES (PADC("小计",FSIZE(FIELD(1)),"-")) * 列合计 FOR I=2 TO FCOUNT() IF TYPE(FIELD(I))="N" SUM EVALUATE(FIELD(I)) TO HJ *--- 数值型字段求和,并将结果添加到最后一条记录 REPLACE RECORD RECCOUNT() (FIELD(I)) WITH HJ IN TEMP ENDIF ENDFOR SELECT TEMP BROWSE