变态的问题,愁死我了!

dushuang 2002-06-03 09:13:57
我用asp在服务器端生成excel文件,怎么在客户端显示?
我做的excel模版,添加数据后,已经生成文件,而且数据正确,但在客户端,紧接着显示(用转页方法)却只显示空的模版,并在服务器端生成新文件,然后重新连接先生成的数据文件,就可以正常显示,不知为何,愁死我了!
...全文
98 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
dushuang 2002-06-06
  • 打赏
  • 举报
回复
感谢 雨一直下,终于解决了!
whz_time 2002-06-06
  • 打赏
  • 举报
回复
请查收您的短信息
Erlei 2002-06-04
  • 打赏
  • 举报
回复
我来学习
啤酒沫 2002-06-04
  • 打赏
  • 举报
回复
现在假定你的Excal文件已经在服务器端生成,按照下面的代码,你可以将Excel发布到Web页面上。
这个程序的功能是:定制Excel模板在Web上发布,让用户填写然后上传到服务器端存档。
其中templet\目录是你的Excel文件存放的路径,temp\目录是临时文件存放的目录这里起到buffer的作用,doc\目录是存放用户填写的Excel文件目录。

<%
set fso=server.CreateObject("Scripting.FileSystemObject")
rootpath=Server.MapPath(".") & "\"
templetpath=rootpath & "templet\"
temppath=rootpath & "temp\"
docpath=rootpath & "doc\"

setp=request("step")
if ucase(setp)="DISPLAY" then
%>
<%
TempletFile=request("SelectFile")
if not fso.FileExists(TempletFile) then
%>
对不起您选择的模版文件不<%=TempletFile%>存在!
<%
Response.End
%>
<%
end if
basename=fso.GetBaseName(TempletFile)
TempFile=temppath & basename & ".htm"
%>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<meta name=ProgId content=FrontPage.Editor.Document>
<meta name=Generator content="Microsoft Excel 9">
<link rel=File-List href="./Page.files/filelist.xml">
</head>

<body><!--[if !excel]>  <![endif]--> <!--下列信息由 Microsoft Excel 的“发布为 Web 页”向导生成。--><!--如果同一条目从 Excel 中重新发布,则所有位于 DIV tag 之间的信息均将得到替换。--><!-----------------------------><!--“从 EXCEL 发布 Web 页”向导开始--><!----------------------------->
<%

doprocess=false
if fso.FileExists(TempFile) then
if fso.GetFile(TempletFile).DateLastModified > fso.GetFile(TempFile).DateLastModified then
fso.DeleteFile(TempFile)
doprocess=true
else
doprocess=false
end if
else
doprocess=true
end if

if doprocess then
set xlApp=server.CreateObject("Excel.Application")
Set xlbook = xlApp.Workbooks.Open(TempletFile)
Set xlsheet = xlbook.Worksheets(1)
xlsheet.SaveAs TempFile,44
Set xlsheet = Nothing
Set xlbook = Nothing
xlApp.Quit
Set xlApp = Nothing
end if

strHtml=fso.OpenTextFile( TempFile).ReadAll()
strHtml=replace(strHtml,"<","<")
strHtml=replace(strHtml,">",">")
strHtml=replace(strHtml,chr(13)& chr(10)," ")
strHtml=replace(strHtml,"""",""")

%>
<div id="Book1_18182" align="center" x:publishsource="Excel">
<OBJECT id=objExclSheet
codebase="file:\\oa-test\setup\office2000\msowc.cab#version=9,0,0,2710"
classid=CLSID:0002E510-0000-0000-C000-000000000046>
<PARAM NAME="HTMLURL" VALUE="TEMP/book1.htm">
<PARAM NAME="HTMLData" VALUE="<%=strHtml%>">
<PARAM NAME="DataType" VALUE="HTMLDATA">
<PARAM NAME="AutoFit" VALUE="-1">
<PARAM NAME="DisplayColHeaders" VALUE="0">
<PARAM NAME="DisplayGridlines" VALUE="-1">
<PARAM NAME="DisplayHorizontalScrollBar" VALUE="0">
<PARAM NAME="DisplayRowHeaders" VALUE="0">
<PARAM NAME="DisplayTitleBar" VALUE="-1">
<PARAM NAME="DisplayToolbar" VALUE="-1">
<PARAM NAME="DisplayVerticalScrollBar" VALUE="0">
<PARAM NAME="EnableAutoCalculate" VALUE="-1">
<PARAM NAME="EnableEvents" VALUE="-1">
<PARAM NAME="MoveAfterReturn" VALUE="-1">
<PARAM NAME="MoveAfterReturnDirection" VALUE="0">
<PARAM NAME="RightToLeft" VALUE="0">
<PARAM NAME="ViewableRange" VALUE="1:65536">
<p style='margin-top:100;font-family:宋体;font-size:8.0pt'>如要交互使用该 Web 页,必须装有
Microsoft (R) Internet Explorer 4.01 或更新版本以及 Microsoft Office Web
Components。请访问 <a
HRef="http://officeupdate.microsoft.com/office/redirect/fromOffice9/MSOWCPub.htm?&HelpLCID=2052">Microsoft
Office Web 站点</a> 以获取更多信息。</p></OBJECT></div><!-----------------------------><!--“从 EXCEL 发布 Web 页”向导结束--><!----------------------------->
<form method="post" name="Modify" onsubmit="return c()">
<input type=hidden name="step" value="SAVE">
<input type=hidden name="SelectFile" value=<%=TempletFile%>>
<input type=submit value="提交表格">
<BR><TEXTAREA name="TableData" rows=30 cols=100 style="display:none"></TEXTAREA>
</form>
</body>
<script>
function c(){
document.Modify.TableData.innerText=objExclSheet.HTMLData;
return true;
}
</script>
</html>
<%
else
if ucase(setp)="SAVE" then
%>
<%
TempletFile=request("SelectFile")
strHtml=Request("TableData")
basename=fso.GetBaseName(TempletFile)
appendname=replace("_" & session.SessionID & "(" & date() & "_" & time() & ")",":",".")
DocFileName=basename & appendname & ".xls"
DocFile=docpath & DocFileName
DocUrl="doc/" & DocFileName
fso.CreateTextFile(DocFile,true).Write(strHtml)

%>
<html>
<body>
文件创建完成,文件名为 <A href="https://spps/<%=DocUrl%>"><%=DocFileName%></a>
</body>
</html>
<%
else
%>

<html>
<body>
请选择所处理的表格模版:
<form name="FileList" method="post" onsubmit="return checkFileList()">
<input type="hidden" name="step" value="DISPLAY">
<%
set TempletFolder=fso.GetFolder(templetpath)
havefile=false
filecount=TempletFolder.Files.Count
for each TempletFile in TempletFolder.Files
if instr(1,TempletFile.Name," ")=0 and ucase(fso.GetExtensionName(TempletFile.Path))="XLT" then
havefile=true
%>
<input type=radio name="SelectFile" value="<%=TempletFile.Path%>"><%=TempletFile.Name%><BR>
<%
end if
next
%>
<%
if havefile then
%>
<BR><input type="submit" value="填表">
<%
else
%>
<BR><input type="submit" value="填表" disabled>
<%
end if
%>
</form>
<script language="JavaScript">
function checkFileList(){
returnvalue=false;
for(i=0;i<<%=filecount%>;i++){
if(document.FileList.SelectFile(i).checked){
returnvalue=true;
break;
}
}
return returnvalue;
}
</script>
</body>
</html>
<%
end if
end if
%>
firmgoal 2002-06-04
  • 打赏
  • 举报
回复
我做过这种事情,在服务器端用Excel.Application对象将数据写入模板,然后保存成EXCEL文件和HTML文件,在客户端用Spreadsheet控件导入HTML文件显示,在页面上还有一个按钮指向EXCEL文件,可以下载。你能不能把你的源代码的主要的部分贴出来让大家看看是什么地方的问题。
dushuang 2002-06-04
  • 打赏
  • 举报
回复
都不是这些问题,初步判定为office的bug,asp 在 Response.Redirect 转换页为office时,session值为空,我在升级office sr-1a升级包!
啤酒沫 2002-06-03
  • 打赏
  • 举报
回复
可以使用OWC来实现页面表格,同时可以添加交互方式。
具体代码我记不清楚了,明天我给你贴出来。
kknd_net 2002-06-03
  • 打赏
  • 举报
回复
学习
孟子E章 2002-06-03
  • 打赏
  • 举报
回复
假如你生成的文件叫xxx.xls,生成后用:
Response.Redirect "xxx.xls"

28,409

社区成员

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

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