Foxtable(狐表)用户栏目专家坐堂 → [求助]关于导出数据


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

主题:[求助]关于导出数据

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


加好友 发短信
等级:小狐 帖子:390 积分:3168 威望:0 精华:0 注册:2008/8/31 20:44:00
[求助]关于导出数据  发帖心情 Post By:2016/5/14 15:35:00 [只看该作者]

导出为Access格式
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Access文件|*.mdb" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
   ex.filepath = dlg.FileName  '指定目标文件
  ex.Export() '开始导出
End If

导出为Excel格式
Syscmd.Project.ExportToExcel()

导出出基本信息表数据或筛选后符合条件的数据, 怎样改代码

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/5/14 16:18:00 [只看该作者]

Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Access文件|*.mdb" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
    ex.filepath = dlg.FileName  '指定目标文件
    ex.Filter = "列名='某值'"
    ex.Export() '开始导出
End If

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/5/14 16:18:00 [只看该作者]

Syscmd.Project.ExportToExcel()没有办法设置条件

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


加好友 发短信
等级:小狐 帖子:390 积分:3168 威望:0 精华:0 注册:2008/8/31 20:44:00
  发帖心情 Post By:2016/5/14 16:25:00 [只看该作者]

Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Access文件|*.mdb" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
    ex.filepath = dlg.FileName  '指定目标文件
    ex.Filter = "列名='某值'"    怎样与下面的代码结合        
    ex.Export() '开始导出
End If

Dim Filter As String
With e.Form.Controls("单位查找")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "使用单位名称 like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("出厂编号查找")   如果查找多个出厂编号,也可以模糊,但不确定多少,用顿号区分, 如:1003、1004、20145 代码怎样改?
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "出厂编号 like '*" & .Value & "*'"
    End If
End With

If Filter > "" Then
    Tables("基本信息表").Filter = Filter
End If

导出为Excel格式 怎样做才能与上面导出为Access格式功能一样
Dim ex as New Exporter
ex
.SourceTableName = "订单" '指定导出表
ex
.FilePath = "c:\Data\订单.xls" '指定目标文件
ex.Format = "Excel" '导出格式为Excel
ex.Fields = "日期,客户,数量,单价" '指定导出字段
ex.Filter = "[产品] = 'PD01'" '指定导出条件
ex.Export() 
'开始导出

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/5/14 16:29:00 [只看该作者]

Dim Filter As String
With e.Form.Controls("单位查找")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "使用单位名称 like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("出厂编号查找")   如果查找多个出厂编号,也可以模糊,但不确定多少,用顿号区分, 如:1003、1004、20145 代码怎样改?
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "出厂编号 like '*" & .Value & "*'"
    End If
End With

If Filter > "" Then
    Tables("基本信息表").Filter = Filter
End If
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Access文件|*.mdb" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
    ex.filepath = dlg.FileName  '指定目标文件
    ex.Filter = Filter     怎样与下面的代码结合        
    ex.Export() '开始导出
End If

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/5/14 16:30:00 [只看该作者]

Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Execl文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
    ex.filepath = dlg.FileName  '指定目标文件
    ex.Filter = Filter     怎样与下面的代码结合  
    ex.Format = "Excel" '导出格式为Excel      
    ex.Export() '开始导出
End If

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


加好友 发短信
等级:小狐 帖子:390 积分:3168 威望:0 精华:0 注册:2008/8/31 20:44:00
  发帖心情 Post By:2016/5/14 16:42:00 [只看该作者]

ex.Filter = Filter 显示代码错误

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/5/14 16:46:00 [只看该作者]

msgbox(Filter)看看是什么东西

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


加好友 发短信
等级:小狐 帖子:390 积分:3168 威望:0 精华:0 注册:2008/8/31 20:44:00
  发帖心情 Post By:2016/5/14 21:19:00 [只看该作者]

菜单设计中按钮Click事件

With  Form("基本信息表").Controls("单位查找")  显示代码错误

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


加好友 发短信
等级:小狐 帖子:390 积分:3168 威望:0 精华:0 注册:2008/8/31 20:44:00
  发帖心情 Post By:2016/5/14 21:58:00 [只看该作者]

Dim Filter As String
With e.Form.Controls("单位查找")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "使用单位名称 like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("出厂编号查找")   
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "出厂编号 like '*" & .Value & "*'"
    End If
End With

If Filter > "" Then
    Tables("基本信息表").Filter = Filter
End If
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Access文件|*.mdb" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "基本信息表" '指定导出表
    ex.filepath = dlg.FileName  '指定目标文件
    ex.Filter = Filter            
    ex.Export() '开始导出
End If

显示器基本信息表 已存在
导出的数据库只有一行空行

实际只想导出基本信息表的数据,当没有按筛选键时就是全部数据,当按了筛选键后就是符合条件的数据
与导出Excel代码功能一样
'Syscmd.Project.ExportToExcel()
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog 
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
     Tables("基本信息表").SaveExcel(dlg.FileName, "基本信息表")  '保存文件
End If
[此贴子已经被作者于2016/5/15 9:55:10编辑过]

 回到顶部
总数 31 1 2 3 4 下一页