Foxtable(狐表)用户栏目专家坐堂 → [求助]如何将一个表的数据加入到另一个表里面?


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

主题:[求助]如何将一个表的数据加入到另一个表里面?

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/2 16:07:00 [显示全部帖子]

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("出库明细导入")
    t.ResumeRedraw()
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets("出库明细")
    For n As Integer = 1 To Sheet.Rows.Count -1
        If sheet(n,5).text > "" Then
            Dim r As DataRow = t.DataTable.Find("出库单号 = '" & sheet(n, 5).text & "' and 数量 = '" & sheet(n, 6).text & "'")
            If r Is Nothing Then r = t.DataTable.AddNew()
            For i As Integer = 0 To sheet.Cols.Count -1
                Dim cname As String = sheet(0, i).text
                If cname > "" AndAlso t.Cols.Contains(cname) Then
                    r(cname) = sheet(n, i).Text
                End If
            Next
        End If
    Next
    t.ResumeRedraw()
End If

 回到顶部