Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xlsx" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
Dim mg As New Merger
mg.SourcePath = dlg.FileName
mg.Format = "Excel2007" \'指定格式
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For n As Integer = 0 To Sheet.Cols.Count -1
Names.add(Sheet(0,n).text)
Next
For Each r As String In v1
If Names.Contains(r)= False \' next 下面的代码也不执行
messagebox.show("excel表中不存在列名为【" & r & "】的列!")
\'Return "excel表中不存在列名为【" & r & "】的列!" \'命令窗口测试需要返回值,窗口事件中将不会弹出返回值.
Return
End If
Next
mg.SourceTableName =Book.Sheets(0).name & "$"
mg.DataTableName = "更新短租实收开票"
mg.Merge()
End If