xls记录数统计
一个目录下有若干xls表,能否用vfp统计出来这个目录下每个表的记录数?每个表就一个sheet1,要求一xls的名称为输出结果:如:
xxxxx.xls,100
yyyyy.xls,20
谢谢!
SET SAFETY off SET engi 70 CLOSE DATABASES PUBLIC mypath cCurrentProcedure = SYS(16,1) nPathStart = AT(":",cCurrentProcedure)- 1 nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart) mypath=SUBSTR(cCurrentProcedure, nPathStart, nLenofPath) SET DEFAULT TO (mypath) SELECT 0 USE filenam alia bmk ZAP aa=ADIR(mm,'*.xlsx') myexcel=createobject('excel.application') &&创建一个对象 IF !VARTYPE(myexcel)$"O.o" &&& 如果用户的电脑上未装EXCEL软件,则结束运行。 MESSAGEBOX("建立EXCEL文件失败,请检查OFFICE是否正常!",48,"提醒:") RETURN ENDIF *----- FOR nn=1 to aa M_File=mypath+'\'+mm(nn,1) bookexcel=myexcel.workbooks.open(M_File) && 打开指定文件 myExcel.Worksheets(1).Activate o_SheetName=myexcel.application.ActiveSheet.Name o_UsedRange =bookexcel.worksheets(o_SheetName).UsedRange o_rows=o_UsedRange.rows.count SELECT bmk APPEND BLANK REPLACE fname with mm(nn,1) REPLACE rs with o_rows - 1 myexcel.activeworkbook.save myexcel.workbooks.close *---进入下一个电子表格 ENDFOR SELECT bmk myexcel.quit CLOSE DATABASES RETURN
[此贴子已经被作者于2020-12-21 07:54编辑过]