以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]导入数据代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73229)

--  作者:方丈
--  发布时间:2015/8/14 15:51:00
--  [求助]导入数据代码

求教:项目中导入数据代码错在哪儿?

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table


 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:任课表.xls


--  作者:大红袍
--  发布时间:2015/8/14 16:26:00
--  
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
dlg.Filter= "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
       
    For Each fl As String In dlg.FileNames
        Dim Book As New xls.Book(fl)
        Dim Sheet As XLS.Sheet = Book.Sheets(0)
        Dim nms As new Dictionary (of String,Integer)
       
        For i As Integer = 0 To Sheet.Cols.Count -1
            If Sheet(0,i).Value <> "" Then
                nms.add(Sheet(0,i).Value,i)
            End If
        Next
        For n As Integer = 1 To Sheet.Rows.Count -1
            Dim bj2 As String = sheet(n,nms("班级")).Text  \'班级
           
            For Each km As String In nms.Keys
                               
                Dim dr As DataRow
                dr = DataTables("分数段统计").Find("班级 = \'" & bj2 & "\' and 科目 = \'" & km & "\'")
                 If dr IsNot Nothing
                    dr("班科任") = sheet(n,nms(km)).text
                End If
            Next
        Next       
    Next
End If