不管转成什么,还是先加工好dbf,之后就好办了
另外:转成excel不好吗?
CLEAR CLOSE TABLES ALL PUBLIC cpath as String LOCAL iArr1 as Integer ,iMax as Integer cpath = 'c:\XIDE\Projects\' && 成绩表和模板文件所在的文件夹。 iMax = 60 && 模板文件可装入人数的最大值。 USE (cpath + '成绩汇总表.DBF') IN 0 SELECT 班级 ,COUNT(*) as 人数 FROM 成绩汇总表 GROUP BY 班级 INTO ARRAY arrbanji FOR iArr1 = 1 TO ALEN( arrbanji ,1) IF arrbanji[iArr1 ,2] > iMax THEN WAIT arrbanji[iArr1 ,1] + '共' + LTRIM(STR(arrbanji[iArr1 ,2])) + ; '人,人数超出模板文件限制,请重新制定模板。程序将跳过制作该班汇总表。' WINDOW AT 10 ,20 TIMEOUT 3 ELSE WAIT arrbanji[iArr1 ,1] + '共' + LTRIM(STR(arrbanji[iArr1 ,2])) + ; '人,程序开始制作该班汇总表。。。' WINDOW AT 10 ,20 NOWAIT SELECT 姓名,语文,数学,英语 FROM 成绩汇总表 INTO ARRAY arrcj where 班级 = arrbanji[iArr1 ,1] = MakeDoc(arrbanji[iArr1 ,1] ,@arrcj) RELEASE arrcj ENDIF NEXT iArr1 USE IN 成绩汇总表 WAIT CLEAR MESSAGEBOX('制作完成,共输出' + LTRIM(STR(ALEN( arrbanji ,1))) + '个文件。',64,'成绩汇总表') RELEASE arrbanji PROCEDURE MakeDoc(bjmc ,arrcj2) LOCAL oApp as Object ,oDoc as Object ,oTab as Object LOCAL cWordFile as String ,cFileOut as String LOCAL iside ,iCol , iRow , ii as Integer STORE 0 TO iside ,iCol , iRow , ii cWordFile = cpath + 'cjtjmb.doc' && 模板文件 cFileOut = cpath + bjmc && 输出文件 oApp = CREATEOBJECT('Word.Application') oDoc = oApp.Documents.Open(cWordFile,0,.t.) oTab = oDoc.Tables(1) For iside = 1 To 2 For irow = 2 To oTab.Rows.Count IF ii < ALEN(arrcj2 ,1 ) THEN For icol = 1 To 4 oTab.cell(irow, icol + 4 * (iside - 1)).Range.Text = arrcj2(irow + 30 * (iside - 1) - 1, icol) Next icol ii = ii + 1 ELSE EXIT ENDIF Next irow Next iside IF FILE(cFileOut) THEN DELETE FILE &cFileOut ENDIF odoc.SaveAs2(cFileOut) oDoc.Close() oApp.Quit() ENDPROC