用代码
Dim dlg As New OpenFileDialog
dlg.Filter= "所有文件|*.*|Excel2003文件|*.xls|Excel2007文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你选择的是:" & dlg.FileName,"提示")
If MessageBox.Show("是否合并?","请确 认!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) = DialogResult.OK Then
DataTables("表A").StopRedraw
Dim App As New MSExcel.Application
try
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
For n As Integer = 2 To rg.Rows.Count
Dim ro As Row = Tables("表A").AddNew
For i As Integer = 0 To Tables("表A").Cols.Count - 1
ro(i) = ws.Cells(n,i+1).Text
Next
Next
MessageBox.Show("导入成功!","恭喜!")
catch ex As exception
msgbox(ex.message)
finally
DataTables("表A").ResumeRedraw
app.quit
End try
End If
End If