Foxtable(狐表)用户栏目专家坐堂 → 合并数据时怎么判定表xls存在指定的表名称


  共有1891人关注过本帖树形打印复制链接

主题:合并数据时怎么判定表xls存在指定的表名称

帅哥哟,离线,有人找我吗?
新航程小何
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:629 积分:4786 威望:0 精华:0 注册:2014/9/17 11:34:00
合并数据时怎么判定表xls存在指定的表名称  发帖心情 Post By:2016/10/18 12:02:00 [只看该作者]

各位老师,合并数据时怎么判定表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

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107880 积分:548763 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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

 回到顶部