Excel怎么这么难处理呢,头疼!!!

happydayandday 2004-10-24 08:15:51
<!--#include file = "dataconn.asp" -->
<html>
<head>
</head>
<body>

<%

set conn=dbConnOpen("hkr")
'on error resume next

'贵重物品购入情况
strsql = "select * from zh_rich_buy_v order by date desc"
set rs = server.CreateObject("adodb.recordset")
rs.Open strsql,conn,1,1

set objExcelApp = CreateObject("Excel.Application")
objExcelApp.DisplayAlerts = false '不显示警告
objExcelApp.Application.Visible = True '显示界面
'objExcelApp.show()
'创建表单
objExcelApp.WorkBooks.add
set objExcelBook = objExcelApp.ActiveWorkBook
set objExcelSheets = objExcelBook.Worksheets
set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.name = "贵重物品购买信息"
objExcelSheet.Range("A1:E1").Value = "贵重物品购买信息"
objExcelSheet.Range("A3:A3").Value = "购入日期"
objExcelSheet.Range("B3:B3").Value = "物品名称"
objExcelSheet.Range("C3:C3").Value = "数量"
objExcelSheet.Range("D3:D3").Value = "单位"
objExcelSheet.Range("E3:E3").Value = "签字"
objExcelSheet.Range("F3:F3").Value = "备注"
%>
<TABLE WIDTH="100%" BORDER="1" CELLSPACING="1" CELLPADDING="1" ID="Table1">
<tr>
<th>购入时间</th>
<th>物品名称</th>
<th>数量</th>
<th>单位</th>
<th>签字</th>
<th>备注</th>
</tr>
<%
for i = 1 to rs.RecordCount
%>
<TR>
<TD>
<%
response.Write tospace(rs("date"))
objExcelSheet.Cells(i+3,1).value = rs("date")
%>
</TD>
<TD>
<%
response.Write tospace(rs("name"))
objExcelSheet.Cells(i+3,2).value = rs("name")
%>
</TD>
<TD>
<%
response.Write tospace(rs("num"))
objExcelSheet.Cells(i+3,3).value = rs("num")
%>
</TD>
<TD>
<%
response.Write tospace(rs("unit"))
objExcelSheet.Cells(i+3,4).value = rs("unit")
%>
<TD>
<%
response.Write tospace(rs("sign"))
objExcelSheet.Cells(i+3,5).value = rs("sign")
%>
</TD>
<TD>
<%
response.Write tospace(rs("memo"))
objExcelSheet.Cells(i+3,6).value = rs("memo")
%>
</TD>

</TD>

</TR>
<%
rs.MoveNext
next
%>
</TABLE>

<%

'保存文档
'objExcelBook.SaveAs server.MapPath(".") & "/new.xls"
'结束进程
objExcelApp.Quit
set objExcelApp = Nothing
%>
</body>
</html>

上面是我写的代码,就是在客户端不启动excel程序,头疼,各位帮忙啊
...全文
228 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
DeltaCat 2004-10-24
  • 打赏
  • 举报
回复
你是想在客户端直接生成呢? 还是在服务器端生成后再下载?
DeltaCat 2004-10-24
  • 打赏
  • 举报
回复
老兄啊, 你写的服务器端的代码, 怎么会在 客户端 启动 EXCEL 呢?

你的代码 是在服务器端 启动 EXCEL 的, 你的理解有偏差
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%>
<table border="1">
<tr>
<th>项目 A</th>
<th>项目 B</th>
<th>合计</th>
<th>项目 C</th>
<th>项目 D</th>
<th>合计</th>
</tr>
<tr>
<td height="30"><%=Request.form("aa")%></td>
<td>3</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td><font color="red">=sum(a2:e2)*100</font></td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td colspan="4"><font color="red">=sum(a3:b3)+f2</font></td>
</tr>
</table>
  • 打赏
  • 举报
回复
objExcelBook.SaveAs server.MapPath(".") & "/new.xls"
保存没成功??
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%>
猜想你可能要这个的效果
serverme 2004-10-24
  • 打赏
  • 举报
回复
关注
happydayandday 2004-10-24
  • 打赏
  • 举报
回复
进程启动了,然后就关了
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%>
<table border="1">
<tr>
<th>项目 A</th>
<th>项目 B</th>
<th>合计</th>
<th>项目 C</th>
<th>项目 D</th>
<th>合计</th>
</tr>
<tr>
<td height="30"><%=Request.form("aa")%></td>
<td>3</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td><font color="red">=sum(a2:e2)*100</font></td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td colspan="4"><font color="red">=sum(a3:b3)+f2</font></td>
</tr>
</table>
看看效果
  • 打赏
  • 举报
回复
楼上他用的是VBA
不是用ADO调用的EXCEL
qunluo 2004-10-24
  • 打赏
  • 举报
回复
~^)^~
happydayandday 2004-10-24
  • 打赏
  • 举报
回复
没有吗???????????????
古侠 2004-10-24
  • 打赏
  • 举报
回复
数据库是用excel吗?
  • 打赏
  • 举报
回复
我是叫你看进程
happydayandday 2004-10-24
  • 打赏
  • 举报
回复
excel本身是没有问题的,可以打开
  • 打赏
  • 举报
回复
资源管理器中呢??
happydayandday 2004-10-24
  • 打赏
  • 举报
回复
恩,明白了,哪位有客户端导出的代码,给我一份,谢了
wanghui0380 2004-10-24
  • 打赏
  • 举报
回复
倒,你用的是在服务器端生成xls文件的代码,呵呵在客户端当然不可以显示拉

我看看你还是先分清楚那些代码是用在服务器端、那些是用在客户端这些基本的概念好了
DeltaCat 2004-10-24
  • 打赏
  • 举报
回复
楼主,你还是概念不清楚啊,

set objExcelApp = CreateObject("Excel.Application")
set objExcelApp = Server.CreateObject("Excel.Application")

上面两种情况, 你放在了<% %> 之内, 效果是一样的, 只是后者效率高一点
-神仙- 2004-10-24
  • 打赏
  • 举报
回复
建立xls文件还是用ado比较好。不容易出问题

happydayandday 2004-10-24
  • 打赏
  • 举报
回复
上面做得table显示只不过是测试,真正想要在客户端调用生产.excel表在服务器段保存是成功了,没有问题的.我想的是能在客户端能直接调用excel程序.上面的代码我用了set objExcelApp = CreateObject("Excel.Application")
而不是set objExcelApp = Server.CreateObject("Excel.Application") 应当是可以直接调用的阿,结果很奇怪,大家帮忙啊
happydayandday 2004-10-24
  • 打赏
  • 举报
回复
当然是客户端,直接生成,调用excel程序,同时具有数据.

28,391

社区成员

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

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