关于excel导入到数据窗口的问题,在线急等.谢谢
在导入时出现这样的错误提示:
application terminated.
error:error calling external object function opne at line 14 in clicked event of object cb_1 of w_main.
请问这是为什么呀?代码是这样的:
OLEObject ExcelServer
ExcelServer = CREATE OLEObject
int excelok
string str_savename
string str_filename
long value
ExcelOK = ExcelServer.ConnectToNewObject( "excel.sheet" )
if excelok <> 0 then
messagebox("连接excel失败,检查你的系统是否安装了office",string(excelok))
return
else
if sle_1.text<>"" then
str_filename=sle_1.text
ExcelServer.application.Workbooks.Open(str_filename)
str_savename="e:\temp.txt"
excelserver.activeworkbook.saveas(str_savename,3)
excelserver.displayalerts=false
ExcelServer.quit()
ExcelServer.DisconnectObject()
DESTROY ExcelServer
value=dw_1.importfile(str_savename)
if value=0 then messagebox(" error","End of file; too many rows")
if value =-1 then messagebox(" error","No rows")
if value=-2 then messagebox(" error"," Empty file")
if value=-3 then messagebox(" error"," Invalid argument")
if value=-4 then messagebox(" error","Invalid input")
if value=-5 then messagebox(" error","Could not open the file")
if value=-6 then messagebox(" error","Could not close the file")
if value=-7 then messagebox(" error"," Error reading the text")
if value=-8 then messagebox(" error","Not a TXT file")
if value=-9 then messagebox(" error","The user canceled the import")
if value=-10 then messagebox(" error","Unsupported dBase file format (not version 2 or 3)")
filedelete(str_savename)
return
else
sle_1.text="请先选择您要导入的文件!"
sle_1.textcolor=16711680
end if
end if