优化后的代码:
SELECT student
nFieldcount = AFIELDS(aMyArray)
MYEXCEL=CREATEOBJECT("EXCEL.APPLICATION")
WITH MYEXCEL
.WORKBOOKS.ADD
.WORKSHEETS("SHEET1").ACTIVATE
.CAPTION="STUDENT实验"
.ACTIVESHEET.PAGESETUP.ORIENTATION=2
.CELLS(1,4)="学生档案"
FOR i=1 TO nFieldcount
.cells(2,i)=ALLTRIM(aMyArray(i,1))
ENDFOR
.VISIBLE=.Y.
ENDWITH
SELECT STUDENT
GO TOP
R=3
C=0
FOR I = R-3 TO RECCOUNT()
WITH MYEXCEL
FOR j=1 TO nFieldcount
ab="STUDENT."+ALLTRIM(aMyArray(j,1))
.CELLS(R,C+j)=&ab
ON ERROR .CELLS(R,C+j)=" "
ENDFOR
ENDWITH
SKIP
IF
EOF()
EXIT
ENDIF
R=R+1
ENDFOR
[[it] 本帖最后由 ibmlang_002 于 2008-11-4 12:25 编辑 [/it]]