| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 738 人关注过本帖
标题:asp+sql导出报表的问题!
只看楼主 加入收藏
xsl
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:32
专家分:3
注 册:2010-8-3
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:8 
asp+sql导出报表的问题!
我用asp做了一个查询页面,想把查询出来的数据导出一个报表。下面是网页图:
图片附件: 游客没有浏览图片的权限,请 登录注册

我想把红色区域导出,最好能在页面中有一个导出报表按钮.
需要怎样做啊!急啊
搜索更多相关主题的帖子: sql asp 
2010-08-04 10:30
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:14 
excel导出功能在网上多的是,可以找找,不过你确定你的代码是用asp写的,而不是用写的吗?

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-08-04 10:38
xsl
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:32
专家分:3
注 册:2010-8-3
收藏
得分:0 
是asp vb
我在网上找了很多,但我都知道那些代码怎么弄的。看不懂!

[ 本帖最后由 xsl 于 2010-8-4 10:48 编辑 ]
2010-08-04 10:46
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
看看你的代码可以吗

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-08-04 11:14
xsl
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:32
专家分:3
注 册:2010-8-3
收藏
得分:0 
<%
 wj=request("wj")
wj= replace(wj, "?", "%")
wj= replace(wj, ".", "%")
wj= replace(wj, "'", "%")     
%>

<%
Dim Recordset1
Dim Recordset1_cmd   
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject (")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_ = "SELECT  actiondate , DeviceName,PrimaryOwner FROM AS c join dbo.ShadowCopyAction AS s on = WHERE FileName like N'%"&wj&"%'"
Recordset1_cmd.Prepared = true
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.Form("text") <> "") Then
  Recordset2__MMColParam = Request.Form("text")
End If
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. xmlns:ice="http://ns.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>多条件查询</title>
<script src="includes/ice/ice.js" type="text/javascript"></script>
<style type="text/css">
#bod {
    height: 200px;
    width: 900px;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: auto;
    margin-left: auto;
}
#form1 {
    height: 30px;
    width: 100%;
    margin-top: 10px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
    text-align: center;
}
.aa {
    background-color: #4799D3;
}
.a1 {
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
}

#qw{
    height: 50px;
    width:900px;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
    background-repeat: repeat-x;
    background-image: url(images/aa_01.jpg);
}
#asd {
    width: 900px;
    height: auto;
    margin-top: 10px;
}
</style>
</head>
<% If Recordset1.EOF And Recordset1.BOF Then %>
<script   language="javascript" type="text/javascript">  
          alert("没有相关信息!");  
  </script>
   <% End If' end Recordset2.EOF And Recordset2.BOF %>
<body>
<div id="bod">

<div id="qw">
<form id="form1" name="form1" method="POST" action="">
 当前查找内容为: <%Response.Write request("wj")%>                                 
    </form>
     
</div>
<div id="asd">
<SCRIPT LANGUAGE="javascript">
<!--
function AutoExcel(){
  var oXL = new ActiveXObject("Excel.Application"); //创建应该对象
  var oWB = oXL.Workbooks.Add();//新建一个Excel工作簿
  var oSheet = oWB.ActiveSheet;//指定要写入内容的工作表为活动工作表
  var table = document.all.data;//指定要写入的数据源的id
  var hang = table.rows.length;//取数据源行数
  var lie = table.rows(0).cells.length;//取数据源列数

  // Add table headers going cell by cell.
  for (i=0;i<hang;i++){//在Excel中写行
    for (j=0;j<lie;j++){//在Excel中写列
      //定义格式
      oSheet.Cells(i+1,j+1).NumberFormatLocal = "@";//将单元格的格式定义为文本
      //oSheet.Cells(i+1,j+1).Font.Bold = true;//加粗
      oSheet.Cells(i+1,j+1).Font.Size = 10;//字体大小
      oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText;//向单元格写入值
    }
  }
  oXL.Visible = true;
  oXL.UserControl = true;
oXL=null
}
//-->
</SCRIPT>

  <table width="900" border="1" id="date" align="center" cellpadding="0" cellspacing="0" >   
   <tr>
      <td colspan="4" align="right">查询日期:
      <%Response.Write Now()%></td>
</tr>
  <tr class="aa">
   <td width="168">计算机名</td>
  <td width="168">用户名</td>
    <td width="151">复制日期</td>
  </tr>
  <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
    <tr>
     <td><%=(Recordset1.Fields.Item("DeviceName").Value)%></td>
      <td><%=Recordset1.Fields.Item("PrimaryOwner").Value%></td>
      <td><%=(Recordset1.Fields.Item("actiondate").Value)%></td>
    </tr>
  
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</table>
</div>
<input type="button" name="out_excel" onclick="AutoExcel();" value="导出到excel">
</div>


</body>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
这是其中的代码段。我在网上找了一个,导出报表代码但不行。


[ 本帖最后由 xsl 于 2010-8-4 12:59 编辑 ]
2010-08-04 12:57
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
果然是asp的代码,我给你转到asp区吧

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-08-04 17:54
xsl
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:32
专家分:3
注 册:2010-8-3
收藏
得分:0 
那谢谢了啊
2010-08-04 19:21
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:0 
帮顶,看看谁会

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-08-05 09:21
xsl
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:32
专家分:3
注 册:2010-8-3
收藏
得分:0 
快帮帮忙啊
2010-08-05 11:59
快速回复:asp+sql导出报表的问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013744 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved