程序代码:
*************************************
* 名称:读取E表中的个人信息
* 思路:
*************************************
SET ENGINEBEHAVIOR 70
SET SAFETY OFF
SET TALK OFF
*---
PUBLIC mypath
cCurrentProcedure = SYS(16,1)
nPathStart = AT(":",cCurrentProcedure)- 1
nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart)
mypath=SUBSTR(cCurrentProcedure, nPathStart, nLenofPath)
SET DEFAULT TO (mypath)
t=SECONDS()
CLOSE DATABASES
SELECT 0
USE 信息汇总表 ALIAS bmk
ZAP
SELECT 0
USE grxx ALIAS kg
MyExcel=createobject('excel.application') &&创建一个对象
IF !VARTYPE(myexcel)$"O.o" &&& 如果用户的电脑上未装EXCEL软件,则结束运行。
MESSAGEBOX("建立EXCEL文件失败,请检查OFFICE是否正常!",48,"提醒:")
RETURN
ENDIF
MyExcel.visible=.T. &&& 对象不可见
MyExcel.DisplayAlerts = .F. &&& 关闭EXCEL的系统对话框
FOR i=1 TO 9
filemc="个人信息采集表00"+STR(i,1)+".xls"
Mb_excel=myexcel.workbooks.open(mypath+"\"+filemc) && 打开指定文件
SELECT bmk
APPEND BLANK
SELECT kg
GO TOP
SCAN
c_fnam=ALLTRIM(kg.字段内容)
c_wz=ALLTRIM(kg.位置)
SELECT bmk
REPLACE ('bmk.'+c_fnam) WITH Mb_excel.activesheet.cells(&c_wz.).text
SELECT kg
ENDSCAN
MyExcel.ActiveWorkbook.close
ENDFOR
*-------
MyExcel.DisplayAlerts = .T. &&& 恢复EXCEL的系统对话框
MyExcel.WorkBooks.close &&& 关闭工作区
MyExcel.QUIT &&& 关闭excel
RELEASE MyExcel &&& 释放对象变量,以完全结束EXCEL的进程
CLOSE DATABASES
? SECONDS()-t
MESSAGEBOX('读取结束!',64,'提示:',1000)
QUIT