..........
FOR j = 1 TO n_jls
GO j
FOR k = 1 TO n_zds
c_name = ALLTRIM(FIELD(k))
oleapp.cells(j+4,k).value = cjlsb.&c_name
ENDFOR
ENDFOR
.........
把上段代码改为
班级_tmp=''
j=4
SCAN
j=j+1
IF ALLTRIM(班级)<>班级_tmp
班级_tmp=班级
IF j>5
oleapp.ActiveSheet.Rows[j].PageBreak = 1
ENDIF
ENDIF
FOR k = 1 TO n_zds
oleapp.cells(j,k).value = EVALUATE(FIELD(k))
ENDFOR
ENDSCAN
另外 b = b+'班级 ='+"'"+c_bj+"'"+' or ' 这句子中的“班级”请加上ALLTRIM(),不然查不出数据