以下是引用吹水佬在2015-12-1 10:49:26的发言:
这样好看点
APPEND FROM DBF(cstr(i))
接受你的建议。现在成功了,也不知何故?改为建立临时库也成功了。
CLEAR
SET TALK OFF
&&关闭命令显示
SET SAFE OFF
y=MESSAGEBOX("必须准备一只空库:xkcjk.dbf!如果没有,请退出重新加入!",4+64,"提醒:是否符合要求!")
IF y=6
sjk=GETFILE('DBF','选择数据库','',0,'查找省发的学考成绩库')
USE xkcjk
ZAP
APPEND FROM &sjk.
CREATE cursor xktjk (bmd c(5),dj c(1),rs n(4),km c(2))&&建立临时库,省得代码结束后还要删除xkjtk.dbf
*CREATE dbf xktjk
(bmd c(5),dj c(1),rs n(4),km c(2))
*USE xktjk
lcs="yw,sx,yy,zz,ls,dl,wl,hx,sw,js"
nrow=Alines(cstr,Strtran(lcs,",",Chr(13)+Chr(10)))
for i=1 to nrow
select bmd,&cstr(i) as dj,count(*) as rs,'&cstr(i)' as km from xkcjk where &cstr(i)<>' 'group by bmd,&cstr(i) into table &cstr(i)
SELECT xktjk
APPEND FROM &cstr(i)
*APPEND FROM DBF(cstr(i)) &&另一种形式
endfor
SELECT bmd,KM,MAX(IIF(DJ=='A',RS,0000)) AS A,MAX(IIF(DJ=='B',RS,000)) AS B,MAX(IIF(DJ=='C',RS,0000)) AS C,MAX(IIF(DJ=='D',RS,000)) AS D,MAX(IIF(DJ=='E',RS,000)) AS E,MAX(IIF(DJ=='A',RS,0000))+MAX(IIF(DJ=='B',RS,000))+MAX(IIF(DJ=='C',RS,0000))+MAX(IIF(DJ=='D',RS,000))+MAX(IIF(DJ=='E',RS,000))AS TOT FROM
xktjk GROUP BY BMD,KM ORDER BY km,bmd INTO TABLE XKCJTJK
COPY TO XKCJTJK TYPE XL5
WAIT "学考成绩统计库二种格式(XKCJTJK.DBF与xkcjtjk.xls)生成完毕!"
WINDOW TIMEOUT 5
AT SROWS()/2,(SCOLS()/4)
ELSE
RETURN
ENDIF
CLEAR ALL
DELETE FILE
ls1.*
DELETE FILE ??.dbf
*DELETE FILE xktjk.dbf
SET TALK On
SET SAFE On