importfile函数的描述:Inserts data into a DataWindow control or DataStore from a file. The data can be tab-delimited text or dBase format 2 or 3.
从描述可看出并不支持从excel直接import的。
我用的也是类似workhand(☆★★★☆) 的OLE方法。
if value <> 1 then ////没取到、或者取消返回
Return false
end if
if luo_excel.connecttoobject("","Excel.Application") <> 0 then
if luo_excel.ConnectToNewObject("Excel.Application") <> 0 then
messagebox(gs_tsxx,'连接excel失败请稍后再试!')
return false
end if
end if
SetPointer(HourGlass!)
ll_col=2
do while 1=1
luo_sub.cells(ll_col,1).copy()
tab_1.tabpage_1.sle_2.paste()
ls_cx=trim(tab_1.tabpage_1.sle_2.text)
if trim(tab_1.tabpage_1.sle_2.text)="" or isnull(tab_1.tabpage_1.sle_2.text) then
exit
end if
tab_1.tabpage_1.sle_2.text=''
ll_col++
loop
//////////Ll_col 记录总的行数
if ll_col<2 then goto out//空的Excel,
//删除PIM_BOM表中原有数据
delete from inv_usedquota2;
tab_1.tabpage_1.dw_8.reset()
tab_1.tabpage_1.dw_8.retrieve()
////////////取数
ll_01=2
//从第三行开始取数
do while ll_01<= ll_col - 1
ll_row=tab_1.tabpage_1.dw_8.insertrow(0)
tab_1.tabpage_1.sle_2.text=''
luo_sub.cells(ll_01,1).copy()
tab_1.tabpage_1.sle_2.paste()
ls_cx=trim(tab_1.tabpage_1.sle_2.text)
if left(ls_cx,1)='"' then
ls_cx=right(ls_cx,len(ls_cx) - 1)
end if
luo_sub.cells(ll_01,5).copy()
tab_1.tabpage_1.sle_2.paste()
ls_cx=trim(tab_1.tabpage_1.sle_2.text)
if left(ls_cx,1)='"' then
ls_cx=right(ls_cx,len(ls_cx) - 1)
end if
tab_1.tabpage_1.sle_2.text=''
tab_1.tabpage_1.dw_8.setitem(ll_row,'de',dec(ls_cx))
luo_sub.cells(ll_01,9).copy()
tab_1.tabpage_1.sle_2.paste()
ls_cx=trim(tab_1.tabpage_1.sle_2.text)
if left(ls_cx,1)='T' or left(ls_cx,1)='t' then
ls_cx='1'
else
ls_cx='0'
end if
tab_1.tabpage_1.sle_2.text=''
tab_1.tabpage_1.dw_8.setitem(ll_row,'fjbs',integer(ls_cx))