DataTables("表1").DataRows.Clear
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
dlg.Filter= "所有文件|*.*|Excel2003文件|*.xls|Excel2007文件|*.xlsx" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
MessageBox.Show("你选择的是:" & dlg.FileName,"提示") ‘这里是否需要修改?显示都选了几个文件?但是FileNames说维数错误!
If MessageBox.Show("是否合并?","请确 认!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) = DialogResult.OK Then
DataTables("表1").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(2) ‘标签2
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim cs() As String = { "123",”131“ } ‘导入列表名列表
For n As Integer = 2 To rg.Rows.Count
Dim ro As Row = Tables("表1").AddNew
For i As Integer = 0 To cs.length - 1
ro(cs(i)) = ws.Cells(n,i+1).Text 是否是这里定义多excel 维度有错误与上面名字?请给润润笔
Next
Next
MessageBox.Show("导入成功!","恭喜!")
catch ex As exception
msgbox(ex.message)
MessageBox.Show("导入失败!","遗憾!")
finally
DataTables("表1").ResumeRedraw
app.quit
End try
Else
\'Return
End If