首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

请大家帮小弟我看一下. 关于access导出exceL的有关问题.

2012-02-20 
请大家帮我看一下. 关于access导出exceL的问题..它提示第52行出错...不清楚是什么问题..错误类型:Microsof

请大家帮我看一下. 关于access导出exceL的问题..
它提示第52行出错...不清楚是什么问题..
错误类型:
Microsoft   VBScript   运行时错误   (0x800A004C)
路径未找到
/page/getexcel.asp,   第   52   行


<!--   #include   file= "conn.inc "-->
<%
way=request.QueryString( "way ")
%>

<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<link   href= "style.css "   rel= "stylesheet "   type= "text/css "   />
</head>
<body>
<table   cellpadding= "0 "   cellspacing= "0 "   border= "0 "   width= "100% ">
<tr   align= "center "   class= "font ">
<td   align= "center "   width= "10% "> <a   href= "clientM.asp "> 客户管理 </a> </td>
<td   align= "center "   width= "10% "> 打印资料 </td>
<td   align= "center "   width= "10% "> <b> 导入Excel </b> </td>
<td   width= "70% "> </td>
</tr>
<tr>
<td   colspan= "4 "   align= "center "> <img   src= "../pic/dt1.gif "   width= "100% "   height= "1 "> </td>
</tr>
<tr>
<td   colspan= "4 ">
<br>
<br>
<br>
<br>
<form   name= "Excel "   method= "post "   action= "getexcel.asp?way=2 ">
<table   cellpadding= "0 "   cellspacing= "0 "   border= "0 "   width= "100% ">
<tr   align= "center ">
<td   align= "center "> 请输入文件名: <input   type= "text "   name= "filename "   value= " "> </td>
</tr>
<tr   align= "center ">
<td   align= "center "> <input   type= "submit "   name= "submit "   value= "确定 "> </td>

</tr>
</table>
</form>
<%if   way=2   then
  response.Write( "正在导入,请稍候! ")  
dim   s,sql,filename,fs,myfile,x,stradd  
filename   =   request.Form( "filename ")  
Set   fs   =   server.CreateObject( "scripting.filesystemobject ")    
'--假设你想让生成的EXCEL文件做如下的存放    
stradd   =   "../excel/ "&filename& ".xls "  
'--如果原来的EXCEL文件存在的话删除它    
if   fs.FileExists(stradd)   then    
        fs.DeleteFile(stradd)    
end     if    
'--创建EXCEL文件    
set   myfile   =   fs.CreateTextFile(stradd,true)    
 
'--从数据库中把你想放到EXCEL中的数据查出来    
sql   =   "select   *   from   client "    
rs.Open  
conn.execute(sql)    
StartTime   =   Request( "StartTime ")


EndTime   =   Request( "EndTime ")
StartEndTime   =   "AddTime   between   # "&   StartTime   & "   00:00:00#   and   # "&   EndTime   & "   23:59:59# "
 
'--将表的列名先写入EXCEL    
        myfile.writeline   strLine    
 
        Do   while   Not   rs.EOF    
                strLine= " "    
 
                for   each   x   in   rs.Fields    
                        strLine   =   strLine   &   x.value   &     chr(9)    
                next    
                myfile.writeline     strLine    
 
                rs.MoveNext    
        loop    
 
   
Response.Write     "生成EXCEL文件成功,点击 <a   href= "&stradd& "> 下载 </a> ! "
rs.Close    
set   rs   =   nothing
Conn.Close
Set   Conn   =   nothing
end   if
%>

</td>
</tr>
</table>
</body>
</html>


[解决办法]
stradd = "../excel/ "&filename& ".xls "
if fs.FileExists(Server.MapPath(stradd))then
fs.DeleteFile(Server.MapPath(stradd))
end if
set myfile = fs.CreateTextFile(stradd,true)

[解决办法]
<%
with response
.AddHeader "Content-Disposition ", "attachment; filename=1.xls "
.ContentType = "application/vnd.ms-excel "
.Flush
end with
%>
<table border= "1 ">
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
</tr>
</table>

即可直接导出excel

热点排行