Foxtable(狐表)用户栏目专家坐堂 → 字段名称


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

主题:字段名称

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


加好友 发短信
等级:童狐 帖子:202 积分:1683 威望:0 精华:0 注册:2011/6/17 16:07:00
字段名称  发帖心情 Post By:2012/10/29 0:32:00 [显示全部帖子]

有些银行对账单下载后,表头字段不规范,如 金额(收入)   现/转,不符合FT字段要求,但是用高速导入没问题,再用代码(判断无重复代码导入,论坛上的)则显示 “XX”列不存在,无法导入,一般修改表结构和修改导入表表头可解决,但我觉得麻烦,请教有没有更简单的方法。(或者能否修改下面代码实现?)

判断无重复导入代码:

Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    For i As Integer = 0 To Sheet.Cols.Count -1
        If CurrentTable.Cols.Contains( Sheet(0,i).Value) = False Then
            MessageBox.Show("目标文件不含【" & Sheet(0,i).Value & "】列,请修改与目标文件一致!", "导入错误提示")
            Return
        End If
    Next
    Dim Filter1 As String
    For r As Integer = 1 To Sheet.Rows.Count - 1
        Filter1 = ""
        For c As Integer = 0 To Sheet.Cols.Count - 1
            If c > 0 Then
                Filter1 = Filter1 & " And "
            End If
            If  CurrentTable.DataTable.DataCols(sheet(0,c).Value).Isnumeric Then
                If sheet(r,c).Value = "" Then
                    Filter1 = Filter1 & sheet(0,c).Value & " is null"
                Else
                    Filter1 = Filter1 & sheet(0,c).Value & " = " & sheet(r,c).Value
                End If
            Else
                If sheet(r,c).Value = "" Then
                    Filter1 = Filter1 & sheet(0,c).Value & " is null"
                Else
                    Filter1 = Filter1 & sheet(0,c).Value & " = '" & sheet(r,c).Value & "'"
                End If
            End If
        Next
        If CurrentTable.DataTable.Find(Filter1) Is Nothing Then
            Dim dr As Row = CurrentTable.AddNew()
            For c As Integer = 0 To Sheet.Cols.Count - 1
                dr(Sheet(0,c).Value) = Sheet(r,c).Value
            Next
        End If
    Next


 回到顶部