以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  数据合并可以简单的看出重复的电话号码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=105017)

--  作者:zoudezhao
--  发布时间:2017/8/10 11:23:00
--  数据合并可以简单的看出重复的电话号码

数据合并时,会有重复的电话有没有什么好的方法可以让重复的电话保存到某一个显眼的位置,或者直接通知重复电话的负责人

简单来说就是合并后会单独把重复的电话列出来方便查询。


--  作者:有点甜
--  发布时间:2017/8/10 11:41:00
--  

 有多行重复的数据?

 

http://www.foxtable.com/webhelp/scr/1478.htm

 

 具体一点你的问题,你如何合并数据的?最后数据是怎样的?要显示什么数据?

 


--  作者:zoudezhao
--  发布时间:2017/8/10 11:47:00
--  

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("表A")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.sqlFind("电话 = \'" & sheet(n, 0).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            newcount += 1
        Else
            oldcount += 1
        End If
 For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                If t.Cols(cname).IsNumeric Then
                    r(cname) = val(sheet(n, i).Text)
                Else
                    r(cname) = sheet(n, i).Text
                End If
            End If
        Next
Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    t.ResumeRedraw()
End If

我是这么合并的但是合并后只会如果有旧数据,只会提示更新旧数据多少条,不会提示都更新了哪些客户,我想具体到可以看到都更新了哪一些客户。


--  作者:有点甜
--  发布时间:2017/8/10 12:27:00
--  
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
    Dim t As Table = Tables("表A")
    t.StopRedraw()
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim newcount As Integer = 0
    Dim oldcount As Integer = 0
    Dim str As String = ""
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim r As DataRow = t.DataTable.sqlFind("电话 = \'" & sheet(n, 0).text & "\'")
        If r Is Nothing Then
            r = t.DataTable.AddNew()
            newcount += 1
        Else
            str &= r("电话") & ","
            oldcount += 1
        End If
        For i As Integer = 0 To sheet.Cols.Count -1
            Dim cname As String = sheet(0, i).text
            If t.Cols.Contains(cname) Then
                If t.Cols(cname).IsNumeric Then
                    r(cname) = val(sheet(n, i).Text)
                Else
                    r(cname) = sheet(n, i).Text
                End If
            End If
        Next
    Next
    msgbox("新增" & newcount & "    " & "更新旧数据" & oldcount)
    msgbox(str.trim)
    t.ResumeRedraw()
End If

--  作者:zoudezhao
--  发布时间:2017/8/10 14:08:00
--  
OK感谢甜老师