CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

关于asp数据库在线导出excel文件问题

楼主daiq8473(代鼠)2006-03-15 13:57:24 在 Web 开发 / ASP 提问

各位大哥,下面是我在网上找的程序修改了一下,运行时出现如下错误,希望各位帮帮忙!高分回报!在线等!  
  错误信息入下:  
  Microsoft   VBScript   运行时错误   错误   '800a01ad'    
   
  ActiveX   部件不能创建对象:   'Excel.Application'    
   
  /admin/dbtoexcel.asp,行   27    
   
  下面是我改的程序  
   
  <%@       LANGUAGE="VBSCRIPT"       %>  
  <HTML>  
  <HEAD>  
  <meta       content="text/html;       charset=gb2312"       http-equiv="Content-Type">  
  <TITLE>生成EXCEL文件</TITLE>  
  </HEAD>  
  <body>  
  <a       href="dbtoexcel.asp?act=make">生成EXCEL</a>  
  <hr       size=1       align=left       width=300px>  
  <%  
  if       Request("act")       =       ""       then  
  '```````````````  
  else  
   
  dim       conn  
  strConn="provider=microsoft.jet.oledb.4.0;data   source="   &   server.mappath("db/ailv_china_reg.mdb")  
  set   Conn=Server.CreateObject("Adodb.Connection")  
  Conn.open   strConn  
   
  dim       rs,sql,filename,fs,myfile,x,link  
  Set       fs       =       server.CreateObject("scripting.filesystemobject")  
  filename       =       "d:\online.xls"  
  if       fs.FileExists(filename)       then  
  fs.DeleteFile(filename)  
  end   if  
   
  set       appExcel=CreateObject("Excel.Application")  
  set       bokExcel=appExcel.Workbooks.Open("online.xls")  
   
   
  'set       myfile       =       fs.CreateTextFile(filename,true)  
  Set       rs       =       Server.CreateObject("ADODB.Recordset")  
  sql       =       "select       *       from       register   "  
  rs.Open       sql,conn  
  if       rs.EOF       and       rs.BOF       then  
  else  
  dim       strLine,responsestr  
  strLine=""  
  For       each       x       in       rs.fields  
  strLine=       strLine       &       x.name       &       chr(9)  
  Next  
  bokExcel.writeline       strLine  
  Do       while       Not       rs.EOF  
  strLine=""  
  for       each       x       in       rs.Fields  
  strLine=       strLine       &       x.value       &       chr(9)  
  next  
  bokExcel.writeline       strLine  
  rs.MoveNext  
  loop  
  end       if  
  rs.Close  
  set       rs       =       nothing  
  conn.close  
  set       conn       =       nothing  
  set       bokExcel       =       nothing  
  Set       fs=Nothing  
  link="<A       HREF="       &       filename       &       ">Open       The       Excel       File</a>"  
  Response.write       link  
  end       if  
  %>  
  </BODY>  
  </HTML> 问题点数:100、回复次数:14Top

1 楼daiq8473(代鼠)回复于 2006-03-15 14:28:28 得分 0

各位大哥,你们帮帮忙吧,小弟先谢了呀!!!急!!!!!!!!!!!!!!!Top

2 楼wwwwb()回复于 2006-03-15 14:56:32 得分 10

ActiveX   部件不能创建对象:   'Excel.Application'   :  
  是否安装EXCEL?  
  不用那么复杂:  
  JET   SQL:  
  SELECT   *   INTO   [EXCEL   8.0;DATABASE=D:\TEMP\123.XLS].SHEETNAME   FROM   TABLENAME  
  Top

3 楼loloo2(若水)回复于 2006-03-15 14:56:39 得分 10

只用一个语句就可以了阿  
  本页面链接到另一个页面2.asp  
  把原来的页面复制一份改名叫2.asp  
  在前面加上  
  <%   response.contenttype="application/vnd.ms-excel"%>  
  即可  
  Top

4 楼daiq8473(代鼠)回复于 2006-03-15 15:29:28 得分 0

大哥,我是在服务器上用,别人要保存的路径是不确定的!请问还有没有其它方法!Top

5 楼daiq8473(代鼠)回复于 2006-03-15 15:30:44 得分 0

loloo2(若水)   :请问我的这个程序有没有错误?Top

6 楼tigerwen01(小虎)回复于 2006-03-15 15:51:34 得分 10

set       appExcel=Server.CreateObject("Excel.Application")试试,或者运行DCOMCNFG命令来设置EXCEL应用程序的EVERYONE权限。  
  DCOMCNFG--安全性--编辑--设置权限  
  Top

7 楼daiq8473(代鼠)回复于 2006-03-15 15:56:59 得分 0

tigerwen01(小虎)(编程艺术化):谢谢你,不过我现在服务器不支持set       appExcel=Server.CreateObject("Excel.Application")有没有其它什么方法?Top

8 楼loloo2(若水)回复于 2006-03-15 16:59:53 得分 10

呵呵,当然是在服务器上的  
  你可以用我这种方法阿.显示成ie下面套用excel的格式,爱怎么保存都行啊  
  你可以试一试,就是显示一个简单表格,最开始地方加上那句话就可以了Top

9 楼daiq8473(代鼠)回复于 2006-03-15 17:24:17 得分 0

loloo2(若水)   :我把这句加上了就显示网页上有错误~Top

10 楼z1982429()回复于 2006-03-15 18:14:54 得分 10

<%@   Language=VBScript   %>  
  <%  
  %>  
  <TABLE   borderColor=#808080   border=1>  
  <THEAD>  
  <TR>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>上海</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>江苏</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>无锡</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>苏州</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>南京</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>常州</FONT></B></TD>  
  </TR>  
  </THEAD>  
  <TBODY>  
  <TR>  
  <TD><B><FONT   face=Arial   color=#000080   size=2>人员数量</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>670</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>250</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>390</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>100</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>300</FONT></B></TD>  
  </TR>  
  <TR>  
  <TD><B><FONT   face=Arial   color=#000080   size=2>工资</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>800</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>800</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>700</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>600</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>600</FONT></B></TD>  
  </TR>  
    <TR>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>汇总</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(B2:B3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(C2:C3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(D2:D3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(E2:E3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=count(F2:F3)</FONT></B></TD>  
  </TR>  
  </TBODY>  
  </TABLE>  
  你把我写的那些中文字段替换成你从数据库中读取的数据,在客户端保存时可以选择保存为excel文件。  
  有什么问题再联系Top

11 楼z1982429()回复于 2006-03-15 18:18:18 得分 40

<%@   Language=VBScript   %>  
  <%  
   
  Response.ContentType   =   "application/vnd.ms-excel"  
   
  %>  
  <TABLE   borderColor=#808080   border=1>  
  <THEAD>  
  <TR>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>上海</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>江苏</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>无锡</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>苏州</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>南京</FONT></B></TD>  
  <TH   BGCOLOR="BLUE"><B><FONT   color=white   face=Arial   size=2>常州</FONT></B></TD>  
  </TR>  
  </THEAD>  
  <TBODY>  
  <TR>  
  <TD><B><FONT   face=Arial   color=#000080   size=2>人员数量</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>670</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>250</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>390</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>100</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>300</FONT></B></TD>  
  </TR>  
  <TR>  
  <TD><B><FONT   face=Arial   color=#000080   size=2>工资</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>800</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>800</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>700</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>600</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#800000   size=2>600</FONT></B></TD>  
  </TR>  
    <TR>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>汇总</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(B2:B3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(C2:C3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(D2:D3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=SUM(E2:E3)</FONT></B></TD>  
  <TD><B><FONT   face=Arial   color=#000000   size=2>=count(F2:F3)</FONT></B></TD>  
  </TR>  
  </TBODY>  
  </TABLE>  
  刚刚应该为这个,不好意思,漏写了一句Top

12 楼loloo2(若水)回复于 2006-03-16 10:13:02 得分 10

在那句下面加上一句试一下  
  <%   response.charset="UTF-8"   %>  
  不要直接在浏览器中显示这页,要别的页链接过来才行的  
  Top

13 楼daiq8473(代鼠)回复于 2006-03-23 10:21:02 得分 0

谢谢各位,问题解觉了!Top

14 楼taochunsong(老桃 http://www.laotao.cn)回复于 2006-03-23 10:49:19 得分 0

loloo2(若水)  
  能不能再   发点自己的搜藏来    
   
  都是好东西啊  
   
  谢谢了  
  输出电子表格的那一招是强啊,简单  
   
   
   
  ——————laomaotao@163.com____  
  Top

相关问题

  • 如何将数据库中的数据导出到excel中阿?
  • paradox数据库表导出excel的问题
  • 请问如何将数据库导出到Excel?
  • 给一段数据库导出excel程序
  • 如何导出文件内容?(数据库方面,ACCESS->DBF,EXCEL...)
  • 在ASP.NET中,如何从数据库中导出EXCEL?(用C#)
  • 数据库导出Excel问题!!急!!不解决就不睡觉!!
  • access数据库里的表怎样导出为word或excel?
  • asp.net(c#)如何把数据库导出一个模板excel中?
  • 如何将数据库中的数据导出到Excel

关键词

  • excel

得分解答快速导航

  • 帖主:daiq8473
  • wwwwb
  • loloo2
  • tigerwen01
  • loloo2
  • z1982429
  • z1982429
  • loloo2

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo