在B/S的客户端,如何用asp调用excel表格来打印报表呢?(急急急急急)

javacayalww 2003-11-28 12:50:21
请各位大虾帮帮小弟,在B/S结构中,我用的语言是asp,如何在客户端调用excel表格来打印报表呢,我也查过一些资料,也都有一些说法,但是都不完整(可能由于小弟是初学),希望那位大虾能给小弟写一个完整的例子,帮帮忙,在此小弟表示万分的感激!!
...全文
140 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
ilqtj 2003-12-20
  • 打赏
  • 举报
回复

//一下是取数据的类
//Obj参数指定数据的来源(限定Table),默认第一行为字段名称行
//GetTableData类提供MoveNext方法,参数是表的行向上或向下移动的位数,正数向下移动,负数向上.
//GetFieldData方法获得指定的列名的数据
//Sort_desc方法对指定的列按降序排列
//Sort_asc方法对指定的列按升序排列
//GetData方法返回字段值为特定值的数据数组,提供数据,可以在外部进行其他处理
//Delete方法删除当前记录,数组减少一行
//初始化,Obj:table的名字,Leftlen:左面多余数据长度,Rightlen:右面多余数据长度,
function GetTableData(Obj,LeftLen,RightLen){
var MyObj=document.all(Obj);
var iRow=MyObj.rows.length;
var iLen=MyObj.rows[0].cells.length;
var i,j;

TableData=new Array();
for (i=0;i< iRow;i++){
TableData[i]=new Array();
for (j=0;j<iLen;j++){
TableStr=MyObj.rows(i).cells(j).innerText;
TableStr=TableStr.substring(LeftLen, TableStr.length-RightLen).Trim();
TableStr=TableStr.replace(/ /gi,"").replace(/\r\n/ig,"");
TableData[i][j]=TableStr;
}
}

this.TableData=TableData;
this.cols=this.TableData[0].length;
this.rows=this.TableData.length;
this.rowindex=0;
}


function movenext(Step){
if (this.rowindex>=this.rows){
return
}

if (Step=="" || typeof(Step)=="undefined") {
if (this.rowindex<this.rows-1)
this.rowindex++;
return;

}
else{
if (this.rowindex + Step<=this.rows-1 && this.rowindex + Step>=0 ){
this.rowindex=this.rowindex + Step;
}
else
{
if (this.rowindex + Step<0){
this.rowindex= 0;
return;
}
if (this.rowindex + Step>this.rows-1){
this.rowindex= this.rows-1;
return;
}
}
}
}


function getfielddata(Field){
var colindex=-1;
var i=0;
if (typeof(Field) == "number"){
colindex=Field;
}
else
{
for (i=0;i<this.cols && this.rowindex<this.rows ;i++){
if (this.TableData[0][i]==Field){
colindex=i;
break;
}
}
}
if (colindex!=-1) {
return this.TableData[this.rowindex][colindex];
}

}



function sort_desc(){//降序
var colindex=-1;
var highindex=-1;
desc_array=new Array();
var i,j;
for (n=0; n<arguments.length; n++){
Field=arguments[arguments.length-1-n];
for (i=0;i<this.cols;i++){
if (this.TableData[0][i]==Field){
colindex=i;
break;
}
}
if ( colindex==-1 )
return;
else
{
desc_array[0]=this.TableData[0];
for(i=1;i<this.rows;i++){
desc_array[i]=this.TableData[1];
highindex=1;
for(j=1;j<this.TableData.length;j++){
if (desc_array[i][colindex]<this.TableData[j][colindex]){
desc_array[i]=this.TableData[j];
highindex=j;
}

}
if (highindex!=-1)
this.TableData=this.TableData.slice(0,highindex).concat(this.TableData.slice(highindex+1,this.TableData.length));
}
}


this.TableData=desc_array;
}
return;
}



function sort_asc(){//升序
var colindex=-1;
var highindex=-1;
var i,j;
for (n=0; n<arguments.length; n++){
asc_array=new Array();
Field=arguments[arguments.length-1-n];
for (i=0;i<this.cols;i++){
if (this.TableData[0][i]==Field){
colindex=i;
break;
}
}
if ( colindex==-1 )
return;
else
{
asc_array[0]=this.TableData[0];
for(i=1;i<this.rows;i++){
asc_array[i]=this.TableData[1];
highindex=1;
for(j=1;j<this.TableData.length;j++){//找出最小的列值
if (asc_array[i][colindex]>this.TableData[j][colindex]){
asc_array[i]=this.TableData[j];
highindex=j;

}

}
if (highindex!=-1)
this.TableData=this.TableData.slice(0,highindex).concat(this.TableData.slice(highindex+1,this.TableData.length));

}
}


this.TableData=asc_array;
}
return;
}



function getData(Field,FieldValue){
var colindex=-1;
var i,j;

GetData=new Array();
if (typeof(Field)=="undefined" || typeof(FieldValue)=="undefined" ){
return this.TableData;
}

for(j=0;j<this.cols;j++){
if (this.TableData[0][j]==Field){
colindex=j;
}
}
if (colindex!=-1){

for(i=1;i<this.rows;i++){
if (this.TableData[i][colindex]==FieldValue){
GetData[i]=new Array();
GetData[i]=this.TableData[i];
}
}
}
return GetData;
}
function DeletE(){
this.TableData=this.TableData.slice(0,this.rowindex).concat(this.TableData.slice(this.rowindex+1,this.TableData.length));
this.rows=this.TableData.length;
return;
}
function updateField(Field,FieldValue){
var colindex=-1;
var i=0;
if (typeof(Field) == "number"){
colindex=Field;
}
else
{
for (i=0;i<this.cols && this.rowindex<this.rows ;i++){
if (this.TableData[0][i]==Field){
colindex=i;
break;
}
}
}
if (colindex!=-1) {
this.TableData[this.rowindex][colindex]=FieldValue;
}


}
function movefirst(){
this.rowindex=0;
}
function movelast(){
this.rowindex=this.rows-1;
}
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
GetTableData.prototype.MoveNext = movenext;
GetTableData.prototype.GetFieldData = getfielddata;
GetTableData.prototype.Sort_asc = sort_asc;
GetTableData.prototype.Sort_desc = sort_desc;
GetTableData.prototype.GetData = getData;
GetTableData.prototype.Delete = DeletE;
GetTableData.prototype.UpdateField = updateField;
GetTableData.prototype.MoveFirst = movefirst;

具体的例子:http://202.119.73.208/NetEAn/com/test/jsprint.htm
andy2001p 2003-12-17
  • 打赏
  • 举报
回复
给你我做的,如果要更好的,请发邮件给我:andy2001p@hotmail.com


http://www.csdn.net/develop/read_article.asp?id=18629
czhncn1 2003-12-17
  • 打赏
  • 举报
回复
不好意思忘了写有邮箱了czhncn@msn.com
czhncn1 2003-12-17
  • 打赏
  • 举报
回复
能给我也发一份吗?我正处在学习阶段
jingindream 2003-12-16
  • 打赏
  • 举报
回复
shleo(sky):给我发一份好吗?jixinquan@163.com
shayao 2003-12-08
  • 打赏
  • 举报
回复
shleo(sky),能给我发一份吗?shayao@tom.com
hshore 2003-12-08
  • 打赏
  • 举报
回复
shleo(sky),还能给我发一份吗?tempeyouhhb@eyou.com
lions911 2003-11-28
  • 打赏
  • 举报
回复
<%
response.buffer = true
'告诉浏览器用word来显示文档内容
Response.ContentType = "application/vnd.ms-excel"

'文档设定

response.AddHeader "content-disposition", "inline; filename=report.xls"

%>

<html>

<head>

<title>报表</title>

</head>

<body bgcolor="#FFFFFF">

<center><h1>报表</h1></center>

<table border=1 cellspacing=0 cellpadding=0 bordercolor=#000000 align=center>

<tr>

<td>用户名</td>

<td>真实姓名</td>

<td>性别</td>

</tr>
=====================================

程序-HTML表格-EXCEL表格-打印
online 2003-11-28
  • 打赏
  • 举报
回复
http://www.ourfly.com/download/downloadlist.aspx?type=Asp
将数据库中的数据写入客户端的excel中
lastest 2003-11-28
  • 打赏
  • 举报
回复
shleo(sky) 发一份给我吧,正好我现在要用,谢谢了
xxsoft 2003-11-28
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<%
strsql="select username,email,realname,birthday,sex, mphone,homeaddr,postcode,homephone,jobaddr,jobphone,oicq,msn,website from [user]"
set rs=conn.execute(strsql)
response.ContentType = "application/vnd.ms-excel"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=classname%>同学录</title>
</head>

<body>
<table border="1" cellspacing="1" cellpadding="1">
<tr bgcolor="#999999">
<td><div align="center"><strong>真实姓名</strong></div></td>
<td><div align="center"><strong>用户名</strong></div></td>
<td><div align="center"><strong>性别</strong></div></td>
<td><div align="center"><b>生日</b></div></td>
<td><div align="center"><b>手机</b></div></td>
<td><div align="center"><strong>家庭地址</strong></div></td>
<td><div align="center"><strong>家庭电话</strong></div></td>
<td><div align="center"><strong>邮编</strong></div></td>
<td><div align="center"><strong>工作地址</strong></div></td>
<td><div align="center"><strong>工作电话</strong></div></td>
<td><div align="center"><strong>email</strong></div></td>
<td><div align="center"><strong>QQ</strong></div></td>
<td><div align="center"><strong>MSN</strong></div></td>
<td><div align="center"><strong>主页</strong></div></td>
</tr>
<%if not rs.eof then
do while not rs.eof%>
<tr>
<td height="20"> <% =rs("realname")%> </td>
<td> <% =rs("username")%> </td>
<td> <% =rs("sex")%>  </td>
<td> <% =rs("birthday")%> </td>
<td> <% =rs("mphone")%>   </td>
<td> <% =rs("homeaddr")%> </td>
<td> <% =rs("homephone")%> </td>
<td> <% =rs("postcode")%> </td>
<td> <% =rs("jobaddr")%> </td>
<td> <% =rs("realname")%> </td>
<td> <% =rs("jobphone")%> </td>
<td> <% =rs("email")%> </td>
<td> <% =rs("oicq")%> </td>
<td> <% =rs("msn")%> </td>
</tr>
<%rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing%>
</table>
</body>
</html>

这是无错的..我主页上的..你自己拿去
cws123 2003-11-28
  • 打赏
  • 举报
回复
也给我一份!cws123@163.com
kokblack 2003-11-28
  • 打赏
  • 举报
回复
http://www.yesky.com/SoftChannel/72342380468043776/20030805/1719195_1.shtml
kokblack 2003-11-28
  • 打赏
  • 举报
回复
也给偶一份!
kokzj@yahoo.com.cn
ny_nicholas 2003-11-28
  • 打赏
  • 举报
回复
我要!!先謝了!
ny_nicholas@hotmail.com
shleo 2003-11-28
  • 打赏
  • 举报
回复

我有客户端生成并下载excel文档的例子
需不需要
需要的话给个信箱地址

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧