//execl文件导入
String st_is_path,st_FILENAME
String st_item_no,st_card_name,st_vip_tel,st_mobile,st_type_name,ll_endxfcs
Long ll_xfcs,st_item_num
String ls_title, ls_str
OLEObject xl, xlApp, xlbook, xlsheet
Int ret = 0
//xl.Close()
//xl.DisconnectObject()
//Destroy xl
xl = Create OLEObject
If tab_1.tabpage_4.rb_1.Checked = True Then //盘点数据(有条件) //盘点文件.dbf
st_is_path = tab_1.tabpage_4.sle_3.Text + "盘点文件.dbf"
ElseIf tab_1.tabpage_4.rb_2.Checked = True Then //盘点数据(无条件) //无条件.dbf
st_is_path = tab_1.tabpage_4.sle_3.Text + "无条件.dbf"
ElseIf tab_1.tabpage_4.rb_3.Checked = True Then //批号盘点 // 批号库存.dbf
st_is_path = tab_1.tabpage_4.sle_3.Text + "批号库存.dbf"
ElseIf tab_1.tabpage_4.rb_4.Checked = True Then //订货数量 // 订货文件.dbf
st_is_path = tab_1.tabpage_4.sle_3.Text + "订货文件.dbf"
ElseIf tab_1.tabpage_4.rb_5.Checked = True Then //验收数量 // 单据文件.dbf
st_is_path = tab_1.tabpage_4.sle_3.Text + "单据文件.dbf"
End If
ret = xl.ConnectToObject(st_is_path, "Excel.Sheet" ) //打开一个已存在的工作表
If ret < 0 Then
MessageBox("提示","不能打开所选的文件,可能是已被占用!")
Destroy xl
Return
End If
xlApp = xl.Application
xlbook = xlApp.Workbooks[1]
xlsheet = xlbook.Worksheets[1]
Long ll_row,i,ll_rowcount
ll_row = xlsheet.UsedRange.Rows.Count
st_6.Text = '导入数据,等待确认!'
Int li_flag
li_flag = MessageBox("导入数据提示","是否追加数据到数据表中,是-追加,否-导入新的数据,取消-放弃导入?",Question!,YesNoCancel!,1)
Choose Case li_flag
Case 1 //用户选择Yes,保存数据
//处理语句
ll_rowcount = tab_1.tabpage_1.dw_1.RowCount()+1
Case 2 //用户选择No,不保存
//删除所有数据包括缓冲区数据
tab_1.tabpage_1.dw_1.RowsMove(1, tab_1.tabpage_1.dw_1.RowCount(), primary!, tab_1.tabpage_1.dw_1,1, Delete!)
ll_rowcount = 1
Case 3 //用户选择了Cancel,不进行任何操作
//处理语句
st_6.Text = "导入数据已放弃!"
MessageBox("导入","导入数据已放弃!")
xl.Close()
//
xl.DisconnectObject()
Destroy xl
Return
End Choose
If ll_row = 0 Then Return
For i = 2 To ll_row
If tab_1.tabpage_4.rb_3.Checked = True Or tab_1.tabpage_4.rb_5.Checked = True Then //批号盘点 // 批号库存.dbf
or
//验收数量 // 单据文件.dbf
st_item_no = String(xlsheet.CELLS(i,2).Value)
st_item_num = Long(xlsheet.CELLS(i,3).Value)
Else
st_item_no = String(xlsheet.CELLS(i,1).Value)
st_item_num = Long(xlsheet.CELLS(i,2).Value)
End If
tab_1.tabpage_1.dw_1.InsertRow(ll_rowcount)
tab_1.tabpage_1.dw_1.SetItem(ll_rowcount,"item_no",st_item_no)
tab_1.tabpage_1.dw_1.SetItem(ll_rowcount,"base_price8",st_item_num)
ll_rowcount = ll_rowcount+1
Next
xlbook.Saved = True
xl.Close()
//xl.DisconnectObject()
Destroy xl
st_6.Text = "数据导入完成,共:" + String(tab_1.tabpage_1.dw_1.RowCount()) +"条记录!"
MessageBox("导入完成","数据导入完成,共:" + String(tab_1.tabpage_1.dw_1.RowCount()
) + "条记录!")