SET talk off
SET SAFETY off
M_File=GETFILE('xls','电子表格文件')
IF M_File=" "
=MESSAGEBOX("请选择待导入的电子表格文件!",0+48,"提示")
RETURN
ELSE
IF JUSTEXT(M_FILE)#"XLS"
=MESSAGEBOX("您选择的不是EXCEL文档!",0+48,"提示")
RETURN
ENDIF
ENDIF
USE ?
ZAP
myexcel=createobject('excel.application')
myexcel.visible=.f.
bookexcel=myexcel.workbooks.open(M_File)
o_SheetName=myexcel.application.ActiveSheet.Name
UsedRange =bookexcel.worksheets(o_SheetName).UsedRange
o_cols=UsedRange.columns.count
IF UsedRange.rows.count<=1
=MESSAGEBOX("待导入数据行数太少,请检查!",0+16,"提示")
ELSE
for i=5 to UsedRange.rows.count
APPEND BLANK
REPLACE xm WITH myexcel.cells(i,2),zymc WITH myexcel.cells(i,3)
ENDFOR
ENDIF
myexcel.workbooks.close &&关闭工作区
myexcel.quit &&关闭excel
brow
这是我的程序原文,运行到REPLACE 那行就报错“CELLS不是一个对象”,然后我将程序挂起,直接到窗口把命令中I换成常量5执行
REPLACE xm WITH myexcel.cells(5,2),zymc WITH myexcel.cells(5,3)就不报错。谢谢各位大侠伸手援助。