Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xls" '设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮 Dim t As Table = Tables("科目余额表") Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) t.StopRedraw() Dim dic As new Dictionary(of String, String) For Each c As Col In t.Cols dic.Add(c.Caption, c.name) Next Dim nms() As String = {"科目编码", "科目名称", "科目或项目"} For n As Integer = 2 To Sheet.Rows.Count -1 Dim r As Row = t.AddNew() For m As Integer = 0 To nms.Length - 1 r(dic(nms(m))) = Sheet(n,m).Value Next Next t.ResumeRedraw() t.ResumeRedraw() End If
|