Foxtable(狐表)用户栏目专家坐堂 → 导入数据报错问题求帮助?


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

主题:导入数据报错问题求帮助?

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/30 14:23:00 [显示全部帖子]

请把excel数据和foxtable例子一起发上来测试。


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/30 15:20:00 [显示全部帖子]

代码没问题,这段代码,必须和excel表的各个列对应。

 

Dim nms() As String = {"评审分组","工作单位","县公司","材料编号","姓名","性别","身份证号码","文化程度","现岗位名称","参加工作时间","现工种工作时间","原技术资格等级","原等级取得时间","原资格证书工种","原资格证书编号","鉴定等级","申报鉴定工种","鉴定批次","申报性质","理论成绩","实操成绩","工作业绩","潜能成绩","总评成绩","评审资格","备注"}


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/30 15:40:00 [显示全部帖子]

汗,顺序要对应啊。

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/30 15:54:00 [显示全部帖子]

 

Dim Result As DialogResult
Result = MessageBox.Show("确定要导入吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
    Dim dlg As New OpenFileDialog
    dlg.Filter = "Excel文件|*.xls"
    dlg.MultiSelect = True '允许选择多个文件
    If dlg.ShowDialog =DialogResult.OK Then
        Dim Book As New XLS.Book(dlg.FileName)
        Dim Sheet As XLS.Sheet = Book.Sheets(0)
        Tables("上会评审表").ResumeRedraw()
        Tables("上会评审表").StopRedraw()
        systemready = False     
        Dim nms() As String = {"","评审分组","工作单位","县公司","材料编号","姓名","性别","身份证号码","文化程度","现岗位名称","参加工作时间","现工种工作时间","原技术资格等级","原等级取得时间","原资格证书工种","原资格证书编号","鉴定等级","申报鉴定工种","鉴定批次","申报性质","理论成绩","实操成绩","工作业绩","潜能成绩","总评成绩","备注"}
        Dim dic As new Dictionary(Of DataRow, Integer)
        Dim ls As new List(Of Integer)
        For n As Integer = 1 To Sheet.Rows.Count -1
            Dim sfzhm As String = sheet(n,7).Text
            Dim jdpc As String = sheet(n,18).Text
            Dim dr As DataRow = DataTables("上会评审表").Find("身份证号码 = '" & sfzhm & "' And 鉴定批次 = '" & jdpc & "'")
            If dr Is Nothing Then
                ls.add(n)
            Else
                dic.Add(dr, n)
            End If
        Next
        For Each key As DataRow In dic.Keys
            For m As Integer = 0 To nms.Length - 1
                If nms(m) = "" Then Continue For
                output.show(m)
                If DataTables("上会评审表").DataCols(nms(m)).IsBoolean Then
                    If Sheet(dic(key),m).Value = 0 Then
                        key(nms(m)) = False
                    Else
                        key(nms(m)) = True
                    End If
                Else If DataTables("上会评审表").DataCols(nms(m)).Expression > "" Then
                    '表达式列
                Else If DataTables("上会评审表").DataCols(nms(m)).IsNumeric Then
                    key(nms(m)) = val(Sheet(dic(key),m).Value)
                Else If DataTables("上会评审表").DataCols(nms(m)).IsDate Then
                    Dim d As Date
                    If Date.TryParse(Sheet(dic(key),m).Value, d)
                        key(nms(m)) = d
                    End If
                Else
                    key(nms(m)) = Sheet(dic(key),m).Value
                End If
            Next
        Next
        For Each l As Integer In ls
            Dim ndr As DataRow = DataTables("上会评审表").AddNew
           
            For m As Integer = 0 To nms.Length - 1
                If nms(m) = "" Then Continue For
                If DataTables("上会评审表").DataCols(nms(m)).IsBoolean Then
                    If Sheet(l,m).Value = 0 Then
                        ndr (nms(m)) = False
                    Else
                        ndr (nms(m)) = True
                    End If
                Else If DataTables("上会评审表").DataCols(nms(m)).Expression > "" Then
                    '表达式列
                Else If DataTables("上会评审表").DataCols(nms(m)).IsNumeric Then
                    ndr (nms(m)) = val(Sheet(l,m).Value)
                Else If DataTables("上会评审表").DataCols(nms(m)).IsDate Then
                    Dim d As Date
                    If Date.TryParse(Sheet(l,m).Value, d)
                        ndr (nms(m)) = d
                    End If
                Else
                    ndr (nms(m)) = Sheet(l,m).Value
                End If
            Next
        Next
        Tables("上会评审表").ResumeRedraw()
        systemready = True
    End If
End If

 


 回到顶部