回复 49楼 antony521
判断物质名称是否为空,决定是否退出循环
坚守VFP最后的阵地
CREATE CURSOR tt (项目名称 C(50),项目编号 C(10),物资名称 C(10),物资型号 C(30)) oExcel=CreateObject('Excel.Application') LOCAL Ar[1,4] =ADIR(aExcel,SYS(5)+SYS(2003)+"\*.XLS") FOR I = 1 TO ALEN(aExcel,1) WITH oExcel .WorkBooks.Open(SYS(5)+SYS(2003)+"\"+aExcel[I,1]) WITH .Sheets(1) Ar[1,1] = .Range("C2").Text Ar[1,2] = .Range("C3").Text nRow=7 DO WHILE .T. IF BETWEEN(ASC(.Cells(nRow,1).Text),49,57) Ar[1,3] = .Cells(nRow,4).Text Ar[1,4] = .Cells(nRow,5).Text ELSE EXIT ENDIF INSERT INTO tt FROM ARRAY Ar STORE "" TO Ar[1,3], Ar[1,4] nRow = nRow + 1 ENDDO ENDWITH ENDWITH ENDFOR oExcel.ActiveWorkBook.Close(.F.) oExcel.Quit Release oExcel SELECT tt BROWSE