以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 合并数据时怎么判定表xls存在指定的表名称 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91747) |
-- 作者:新航程小何 -- 发布时间:2016/10/18 12:02:00 -- 合并数据时怎么判定表xls存在指定的表名称 各位老师,合并数据时怎么判定表xls存在指定的表名称,也就是如果指定表名称存在合并数据,要是不存在提示重新选择 Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*xlsx" dlg.MultiSelect = False If dlg.ShowDialog =DialogResult.OK Then Dim fl As String = dlg.FileName Dim mg As New Merger mg.Format = "excel" mg.SourcePath = fl mg.SourceTableName = "临时工表$" mg.DataTableName="临时工表" mg.Merge() MessageBox.show("导入成功!","提示") DataTables("临时工表").DataCols("时间").RaiseDataColChanged() End If
|
-- 作者:有点蓝 -- 发布时间:2016/10/18 12:25:00 -- http://www.foxtable.com/webhelp/scr/1152.htm Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*xlsx" dlg.MultiSelect = False Dim find As Boolean Do While not find If dlg.ShowDialog =DialogResult.OK Then Dim fl As String = dlg.FileName Dim Book As New XLS.Book(fl) For Each Sheet As XLS.Sheet In Book.Sheets If sheet.name = "临时工表" Then find = True Exit For End If Next If find Then Dim mg As New Merger mg.Format = "excel" mg.SourcePath = fl mg.SourceTableName = "临时工表$" mg.DataTableName="临时工表" mg.Merge() MessageBox.show("导入成功!","提示") DataTables("临时工表").DataCols("时间").RaiseDataColChanged() Else If MessageBox.Show("文件不正确,是否重新选择?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Exit Do End If End If Loop |