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/
本文提供了一个使用特定脚本语言从Excel文件中读取指定列数据的例子,并展示了如何通过OLE对象连接到Excel应用程序,打开文件并逐行读取所需的数据。
&spm=1001.2101.3001.5002&articleId=100229010&d=1&t=3&u=f1f974b7c6704a25aa26e4827fe3daee)
707

被折叠的 条评论
为什么被折叠?



