樓主的Excel文件格式有問題:無法按設定的合併條件合併(Excel文件格式最好為2003)
Dim n1,n2 As Integer
n1 = DataTables("SPXX").DataRows.count-1
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim mg As New Merger
mg.SourcePath = dlg.FileName
mg.Format = "excel" '指定格式
mg.SourceTableName = "Sheet1$" '指定要合并的表
mg.DataTableName = "SPXX" '指定接收数据的表
mg.Merge() '开始合并
mg.filter ="新EG号 > ''"
End If
If n1 < DataTables("SPXX").DataRows.count-1 Then
For n2 = n1 To 0 Step -1
dr1 = DataTables("SPXX").Find("新EG号 = '" & Tables("SPXX")(n2,"新EG号") & "' and [_Identify]> " & Tables("SPXX")(n2,"_Identify"))
If dr1 IsNot Nothing Then
Tables("SPXX").Rows(n2).Delete
End If
Next
End If
DataTables("SPXX").Save
[此贴子已经被作者于2013-5-19 15:33:14编辑过]