Foxtable(狐表)用户栏目专家坐堂 → 求助


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

主题:求助

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2014/3/28 13:40:00 [显示全部帖子]

你上面的已经不会重复导入了,要提示的话:

 

Dim Book As New XLS.Book("e:\面积计算表.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)

Dim s as string
Tables("订单明细表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"单号","客户订单号","工程名称","编号","数量","长度1","长度2","长度3","长度4","宽度1","宽度2","宽度3","宽度4"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
    Dim dh As String = sheet(n,0).Text
    If DataTables("订单明细表").Find("单号 = '" & dh & "'") Is Nothing Then '如果不存在同编号的订单
        Dim r As Row = Tables("订单明细表").AddNew()
        For m As Integer = 0 To nms.Length - 1
            r(nms(m)) = Sheet(n,m).Value
        Next

     Else

          s = s & " " & dh
    End If
Next

Tables("订单明细表").ResumeRedraw()

if s > "" then

    Messagebox.show("以下单号重复,没有导入:" & s)

end if


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2014/3/28 16:38:00 [显示全部帖子]

当然可以:

 

Dim Book As New XLS.Book("e:\面积计算表.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)

Dim s as string
Tables("订单明细表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"单号","客户订单号","工程名称","编号","数量","长度1","长度2","长度3","长度4","宽度1","宽度2","宽度3","宽度4"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
    Dim dh As String = sheet(n,0).Text
    If DataTables("订单明细表").Find("单号 = '" & dh & "'") Is Nothing Then '如果不存在同编号的订单
        Dim r As Row = Tables("订单明细表").AddNew()
        For m As Integer = 0 To nms.Length - 1
            r(nms(m)) = Sheet(n,m).Value
        Next

        r("订单编号") = Tables("订单").Current("订单编号")

     Else

          s = s & " " & dh
    End If
Next

Tables("订单明细表").ResumeRedraw()

if s > "" then

    Messagebox.show("以下单号重复,没有导入:" & s)

end if


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2014/3/28 17:49:00 [显示全部帖子]

Dim Book As New XLS.Book("e:\面积计算表.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)

Dim s as string
Tables("订单明细表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"单号","客户订单号","工程名称","编号","数量","长度1","长度2","长度3","长度4","宽度1","宽度2","宽度3","宽度4"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
    Dim dh As String = sheet(n,0).Text
    If DataTables("订单明细表").Find("单号 = '" & dh & "'") Is Nothing Then '如果不存在同编号的订单
        Dim r As DataRow = DataTables("订单明细表").AddNew()
        For m As Integer = 0 To nms.Length - 1
            r(nms(m)) = Sheet(n,m).Value
        Next

        r("订单编号") = Tables("订单").Current("订单编号")

     Else

          s = s & " " & dh
    End If
Next

Tables("订单明细表").ResumeRedraw()

if s > "" then

    Messagebox.show("以下单号重复,没有导入:" & s)

end if


 回到顶部