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)
Tables("入账表").StopRedraw()
Dim nms() As String ={"序号","日期","保险人","险种","使用性质","保单号","投保人","被保险人","保费","业务员","业务员卡号","引荐人","起保时间","备注"}
For n As Integer = 1 To Sheet.Rows.Count -1
Dim bdh As String = sheet(n,5).Text '保单号
Dim bf As String = sheet(n,8).Text '保费
If DataTables("入账表").Find("保单号 = '" & bdh & "' and 保费 = '" & bf & "'") Is Nothing Then '如果不存在重复的记录;
Dim r As Row = Tables("入账表").AddNew()
For m As Integer = 0 To nms.Length - 1
If DataTables("入账表").DataCols(nms(m)).IsNumeric Then
r(nms(m)) = Val(Sheet(n,m).Value)
Else
If Tables("入账表").cols(nms(m)).IsDate Then
Dim d As Date
If Date.TryParse(Sheet(n,m).Value,d) Then
r(nms(m)) = d
End If
Else
r(nms(m)) = Sheet(n,m).Value
End If
End If
Next
End If
Next
End If