ASP是否可以在 页面 调用 并显示 Excel 表格??

jiejifeng 2002-07-15 11:02:02
请问可以吗, 怎么调用 ,请 写出 代码, 多谢!!
...全文
104 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
MeXP 2002-07-15
  • 打赏
  • 举报
回复
这里有几个例子,你看一下
http://www.csdn.net/Subject/15/index.shtm
jackeroo 2002-07-15
  • 打赏
  • 举报
回复
http://www.csdn.net/Develop/Read_Article.asp?Id=13966
ASP读EXCEL2000的文章!!!
这篇文章对你应该有些帮助!
水墨画 2002-07-15
  • 打赏
  • 举报
回复
当然可以了
<%@ LANGUAGE="VBSCRIPT" %>

<!--#include file="include/config.asp"-->
<%
'EXAMPLE AS:把数据库中一个每天24小时在线人数放到一个EXCEL文件中去
'AUTHOR :钢铁工人
'EMAIL :hello_hhb@21cn.com
'DATE :2001-3-25
'TEST :在NT4,SP6,SQL SERVER 7.0,EXCEL2000中测试通过
%>
<HTML>
<HEAD>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<TITLE>生成EXCEL文件</TITLE>
</HEAD>
<body>
<a href="excel.asp?act=make">生成在线人口的EXCEL</a>
<hr size=1 align=left width=300px>
<%
if Request("act") <> "" then
'dim conn
'set conn=server.CreateObject("adodb.connection")
'conn.Open "test","sa",""
'conn.Open Application("connstr")
dim rs,sql,filename,fs,myfile,x,link
Set fs = server.CreateObject("scripting.filesystemobject")
'--假设你想让生成的EXCEL文件做如下的存放
filename = "c:\online.xls"
'--如果原来的EXCEL文件存在的话删除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
Set rs = Server.CreateObject("ADODB.Recordset")
'--从数据库中把你想放到EXCEL中的数据查出来
sql = "select username,name,sex from t_user order by id asc"
rs.Open sql,cn,3,1
if not rs.EOF then
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
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
end if
rs.Close

'--从数据库中把你想放到EXCEL中的数据查出来
sql1 = "select username1,name1,sex1 from t_usera order by id asc"
rs.Open sql1,cn,3,1
if not rs.EOF then
dim strLine1,responsestr1
strLine1=""
For each x in rs.fields
strLine1= strLine1 & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
myfile.writeline strLine1
Do while Not rs.EOF
strLine1=""
for each x in rs.Fields
strLine1= strLine1 & x.value & chr(9)
next
'--将表的数据写入EXCEL
myfile.writeline strLine1
rs.MoveNext
loop
end if
rs.Close

set rs = nothing
cn.close
set cn = nothing
set myfile = nothing
Set fs=Nothing
link="<A HREF=" & filename & ">Open The Excel File</a>"
Response.write link
end if
%>
</BODY>
</HTML>

28,404

社区成员

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

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