“计时工资库” 表中,有姓名,相当的 月份、年份,现在想做一个按键,从外面的excel中导入对应年份、月份的 公积金进来,
合并代码我会,但是筛选和过滤的代码不知道怎么修改,麻烦指导下:
For Each dr As Row In Tables("计时工资库").rows
Dim drr As DataRow
Dim Filter As String '定义一个新筛选数
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls;*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim count As Integer = DataTables("计时工资库").datarows.count
Dim mg As New Merger
mg.SourcePath = dlg.FileName
mg.Format = "excel"
mg.SourceTableName = "sheet1$"
mg.DataTableName = "计时工资库"
Filter = "[年份] = '" & dr("年份
此主题相关图片如下:公积金.png
") & "' and [月份] = '" & dr("月份") & "' and [姓名] = '" & dr("姓名") & "'" drr = DataTables("sheet1").Find(Filter)
drr = DataTables("sheet").Find(Filter)
If drr IsNot Nothing Then '如果找到
dr("公积金") = drr("公积金")
Else
MessageBox.Show( dr("姓名") & " 员工的公积金数据找不到,请检查其姓名和公积金")
Return
mg.Merge()
msgbox(DataTables("计时工资库").datarows.count - count)
End If
Next
End If
End If