string path_name,file_name
if GetFileOpenName( "选择导入的文件... ", path_name, file_name, "XLS ", "Excel Files (*.XLS),*.XLS ") = 1 then
else
return
end if
if fileexists(path_name) then
else
return
end if
long i,ll_row,i_return
oleobject xlapp,xlsub
xlapp = CREATE OLEObject
i_return = xlapp.ConnectToNewObject( "Excel.Application ")
if i_return <> 0 then
MessageBox( "错误! ", "无法启动excel程序! ")
return
end if
xlapp.application.workbooks.open(path_name)
xlsub = xlapp.application.activeworkbook.worksheets[2]
do while len(string(xlsub.cells(i,9).value)) > 0
goods_code = trim(string(xlsub.cells(i,9).value))
goods_num = double(xlsub.cells(i,5).value)
goods_price = double(xlsub.cells(i,6).value)
goods_sum_value = round(double(xlsub.cells(i,7).value),2)
goods_name = trim(string(xlsub.cells(i,1).value))
i = i + 1
loop
xlapp.DisplayAlerts = False
xlapp.Workbooks.close
xlapp.DisplayAlerts = true
xlapp.DisconnectObject()
Destroy xlapp
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/631872/viewspace-1048718/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/631872/viewspace-1048718/