您现在的位置: PQ秀秀网 >> PQ知道 >> 正文 用户登录 新用户注册
把access数据转换成excel Web 开发 / ASP
作者:佚名    文章来源:不详    点击数:加载中...    更新时间:2008-7-12 字体:[ ]
添加到收藏: 添加到百度收藏  收藏到QQ书签  添加到雅虎收藏  添加到新浪ViVi  添加到天极网摘  添加到和讯网摘

把access数据转换成excel

楼主ghgang()2006-12-21 09:51:46 在 Web 开发 / ASP 提问

怎样用asp语句把access数据转换成excel 问题点数:20、回复次数:3Top

1 楼happynet(快乐数据)回复于 2006-12-21 10:08:48 得分 0

<%  
    Server.Scripttimeout=99999999  
  db="kkdata.mdb"  
  ConnStr   =   "Provider   =   Microsoft.Jet.OLEDB.4.0;Data   Source   =   "   &   Server.MapPath(db)  
  set   conn=server.createobject("ADODB.CONNECTION")  
  conn.open   connstr  
  dim     rs,sql,filename,fso,myfile,x  
   
      Set   fso   =   server.CreateObject("scripting.filesystemobject")      
      filename   =   Server.MapPath(session("adminkk")&".xls")      
      if   fso.FileExists(filename)   then  
        fso.DeleteFile(filename)      
      end   if  
      '--创建EXCEL文件  
      set   myfile   =   fso.CreateTextFile(filename,true)  
   
      Set   rs   =   Server.CreateObject("ADODB.Recordset")  
      sql   =   "select   ic_company   as   公司名称,ic_tel   as   电话,ic_fax   as   传真,ic_linkman   as   联系人,ic_address   as   地址,ic_mail   as   邮件,ic_number   as   型号,ic_weizhi   as   库存位置,ic_shengchan   as   制造商,ic_pihao   as   批号,ic_fengzhuang   as   封装,ic_shuliang   as   数量,ic_info   as   描述,ic_now   as   日期   from   ic_table   "      
      rs.Open   sql,conn,1,1  
      if   rs.EOF   and   rs.BOF   then  
      response.write("<script>alert('无数据导出!!');location.href='geturl.asp';</script>")  
      response.end  
      else  
        dim   strLine,responsestr      
        strLine=""  
              '--将表的列名先写入EXCEL      
        For   each   x   in     rs.fields  
          strLine   =   strLine   &   x.name   &   chr(9)  
        Next  
        myfile.writeline   strLine  
          Do   while   Not   rs.EOF      
          strLine=""  
          for   each   x   in     rs.Fields      
            strLine   =   strLine   &   x.value   &   chr(9)      
          next  
          '--将表的数据写入EXCEL      
          myfile.writeline   strLine  
          rs.MoveNext  
        loop  
        response.write("<script>alert('已经导出!!');</script>")  
            response.write("<script>setTimeout('window.opener=null;history.back();',2800);location='"&session("admin_name")&".xls';</script>")  
      end   if  
      rs.Close      
      set     rs     =     nothing  
  Response.ContentType="application/x-msdownload"  
   
  %>  
  Top

2 楼cowens(志眩)回复于 2006-12-21 10:58:35 得分 0

用数据库地层技术,获取表结构然后创建同样结构的excel,最后传输数据.Top

3 楼yuanxiaolei(袁小磊)回复于 2006-12-21 22:40:48 得分 0

http://piaoyhl.piaoy.cn/piaoyhl.txt  
   
  excel导入和导出  
   
  是我的商业程序Top

文章录入:andy    责任编辑:andy 
  网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)