我有段PB的代码,每次只能读取Excel的一个表,现在我想让它读取一个Excel文件中的每张表,不知如何修改,请大哥帮忙谢谢!if is_filename = '' then
Getfileopenname("Select ASN File", is_filename, ls_dummy, &
"XLS", "EXCEL Files (*.XLS), *.XLS")
end if
if is_filename='' or isnull(is_filename) then
return -1
end if
Ole_object = CREATE OLEObject
IF Ole_object.ConnectToObject("","Excel.Application") <> 0 THEN
IF Ole_object.ConnectToNewObject("Excel.Application")<>0 THEN
MessageBox('OLE Error','OLE Can not connect!')
Return 0
END IF
END IF
Ole_object.Workbooks.Open(is_filename)
//get the all cell and set on the datawindow
if isnull(string(Ole_object.activesheet.cells(1,1).value)) = true then
Messagebox('Erroe','File is null,please check it!')
end if
for i = 1 to 65527
if isnull(string(Ole_object.activesheet.cells(i,1).value)) = true then
ll_row_excel = i - 1
exit;
end if
next
for i = 1 to ll_row_excel
ls_To_Lot = string(ole_object.ActiveSheet.Cells(i,1).value)
ls_Mother_Lot = string(ole_object.ActiveSheet.Cells(i,3).value)
IF ls_date = ls_compare_date THEN
ll_rowcount = tab_main.tabpage_cp.dw_cp.insertrow(0)
tab_main.tabpage_cp.dw_cp.Setitem(ll_rowcount,'Subcon_Code','JG')
tab_main.tabpage_cp.dw_cp.Setitem(ll_rowcount,'Process_Code','CP')
tab_main.tabpage_cp.dw_cp.Setitem(ll_rowcount,'trans_date',date(ls_trans_date))
tab_main.tabpage_cp.dw_cp.Setitem(ll_rowcount,'trans_time',time(ls_trans_date))
END IF
next
Ole_object.Workbooks.close
Ole_object.DisConnectObject()
Destroy Ole_Object
RETURN