Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excle|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim t As Table = Tables("工资总表导入")
t.StopRedraw()
Dim c As Integer = t.Rows.Count
Dim dict As new Dictionary(of Integer,String)
For sc As Integer = 0 To sheet.Cols.Count -1
If t.Cols.Contains(sheet(0,sc).Value) Then
dict.Add(sc,sheet(0,sc).Value)
End If
Next
For sr As Integer = 1 To sheet.Rows.Count -1
Dim r As Row = t.AddNew
For Each i As Integer In dict.Keys
r(dict(i)) = sheet(sr,i).Value
Next
Next
t.ResumeRedraw()
MessageBox.Show("导入完成,共导入" & t.Rows.Count - c & "条记录")
End If