Foxtable(狐表)用户栏目专家坐堂 → 求从外部数据源中导出数据到excel的最快方法


  共有11965人关注过本帖平板打印复制链接

主题:求从外部数据源中导出数据到excel的最快方法

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


加好友 发短信
等级:四尾狐 帖子:928 积分:7769 威望:0 精华:13 注册:2008/9/1 11:58:00
求从外部数据源中导出数据到excel的最快方法  发帖心情 Post By:2010/5/22 19:38:00 [只看该作者]

目的:从数据源erp中使用sql语句提取数据然后直接导出到固定的目录,格式为excel格式。

 

原方法:

 

Dim q_a As new QueryBuilder
q_a.TableName = "cw"
q_a.C
q_a.SelectString = "select a.deptcode as '部门编码',d.name as '部门名称',round(sum(b.finishnum*c.inventoryprice/a.plannum*(a.plannum-a.finishnum)),2) as '车间物料' from aeg00000 a,agb00000 b,baa00000 c,zad00000 d where a.centercode='0100' and a.finishnum<a.plannum and a.planid=b.planid and b.finishnum>0 and c.warehousecode like '01%' and b.itemcode=c.itemcode and a.deptcode=d.code group by a.deptcode,d.name order by a.deptcode"
q_a.Build
Dim ex as New Exporter
ex.SourceTableName = "cw" '指定导出表为车间物料
ex.FilePath = "D:\Data\chejian\" & format(Date.now,"yyyy年MM月dd日HH时mm分") & "车间物料" & ".xls" '指定目标文件
ex.Format = "Excel" '导出格式为Excel
ex.Export() '开始导出

 

但是这种方法会生成一个table表cw,如果不希望生成cw表就从后台直接导出为EXCEL表,有没有其他更好的方法?



 回到顶部