Foxtable(狐表)用户栏目专家坐堂 → [求助]导入时过滤掉某些行


  共有2381人关注过本帖树形打印复制链接

主题:[求助]导入时过滤掉某些行

帅哥哟,离线,有人找我吗?
huhu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1182 积分:8225 威望:0 精华:0 注册:2015/3/30 10:44:00
[求助]导入时过滤掉某些行  发帖心情 Post By:2016/6/23 17:41:00 [只看该作者]

导入销售出库单列表.xls时,希望对仓库编码为15的不导入。怎么弄?

 

Dim App As New MSExcel.Application
try
    Dim Wb As MSExcel.Workbook = App.WorkBooks.Open("D:\销售出库单列表.xls")
    Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
   
    Tables("销售出库单列表").StopRedraw()
    '注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
    Dim ra = ws.UsedRange
    Dim nms() As String = {"制单人","仓库编码","仓库","销售订单号","发货单号","出库日期","出库单号","出库类别","销售部门","业务员","客户名称","备注","存货编码","存货名称","主计量单位","数量","货运单号","发货地址"}
    '注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
    For n As Integer = 2 To ra.Rows.Count
        Dim fhdh As String = ws.cells(n,5).Text
        Dim chbm As String = ws.cells(n,13).text
       
        If DataTables("销售出库单列表").Find("发货单号 = '" & fhdh & "' and 存货编码 = '" & chbm & "'") Is Nothing Then '如果不存在同编号的计划表
            Dim r As Row = Tables("销售出库单列表").AddNew()
            For m As Integer = 0 To nms.Length - 1
                r(nms(m)) = ws.cells(n,m+1).Value
            Next
        End If
    Next
    Tables("销售出库单列表").ResumeRedraw()
    Tables("销售出库单列表").save
    msgbox("导入完成")
catch ex As exception
    app.quit
End try


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/6/23 17:43:00 [只看该作者]

For n As Integer = 2 To ra.Rows.Count

    If ws.cells(n,2).Text <> 15 Then
        Dim fhdh As String = ws.cells(n,5).Text


 回到顶部