如何把一个Excel文件放到ASP页面中去?_编程10000问

<%
set xlApp = Server.CreateObject("Excel.Application")
xlApp.Visible = false<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

' 使服务端不出现Excel窗口.
set myWorkbook = xlApp.Workbooks.Add

' 建立一个worksheet.
set myWorksheet = myWorkbook.Worksheets(1)
myWorksheet.Range("A1").Value = '精彩春风通讯录'
myWorksheet.Range("A1").Font.Size = 12
myWorksheet.Range("A1").Font.Bold = true
myWorksheet.Range("A2").Value = '姓名'
myWorksheet.Range("B2").Value = '地址'
myWorksheet.Range("C2").Value = '电话'
myWorksheet.Range("D2").Value = '手机'

' 以上7行建立表头.
myWorksheet.Range("A2:D2").Font.Bold = true
strFileName = Session.SessionID & ".xls"

' 确保文件名唯一.
strAppPath = Request.ServerVariables("PATH_trANSLATED")
strAppPath = Left(strAppPath, InstrRev(strAppPath, "\"))
strFullPath = strAppPath & strFileName
myWorkbook.SaveAs(strFullPath)

' 保存文件.
myWorkbook.Close

' 关闭Excel.
xlApp.Quit
set myWorksheet = Nothing
set myWorkbook = Nothing
set myxlApp = Nothing
Response.Redirect strFileName

' 写到ASP页面,即浏览器中.
%>
[1]

时间: 2024-08-02 21:31:39

如何把一个Excel文件放到ASP页面中去?_编程10000问的相关文章

如何计算下载一个文件需要多长时间?_编程10000问

<%Function DownloadTime(intFileSize, strModemType)Dim TimeInSeconds, ModemSpeed, strDownloadTime, AppendStringDim intYears, intWeeks, intDaysDim intHours, intMinutes, intSecondsintYears = 0intWeeks = 0intDays = 0intHours = 0intMinutes = 0intSeconds =

如何制作一个弹出式的调查窗口?_编程10000问

    <%    Dim bSurvey  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 是否显示调查表    const bID="1"  ' 调查表的id     bSurvey=false    ' 检查调查表是否已经显示过.    if instr(request.Cookies("s"),":&q

如何做一个计数器并让人家申请使用?_编程10000问

第一步,创建一个计数器(最简单的数字计数器,不是图片式的): <% @language="vbscript" %>  <%  set fsFilesys=CreateObject("Scripting.FileSystemObject") set myText=fsFilesys.OpenTextFile(Server.MapPath("/count")&"\count.txt")count=myTe

如何做一个只搜索本网站的引擎?_编程10000问

searchfiles.html <html> <head> <title>撼雪喷云之本网搜索引擎</title> </head> <body> <form method="POST" action="cgi-bin/searchfiles.asp">   <table border="0" cellpadding="5" bgcolor

如何做一个检索结果带链接的检索?_编程10000问

如何做一个检索结果带链接的检索?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <% data=request.form("search_data") ' 从FORM变量集得到要查询的文件名称所要包含的字符串 p=search_folder(data,"http://jack/cgi-bin","c:\intels

如何获知文件被改动的情况?_编程10000问

Function File_GetLastModified( sFile ) Dim objFileObj, objFile  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Set objFileObj = CreateObject("Scripting.FileSystemObject")   If sFile = "" Th

如何编写一个过滤掉HTML代码的函数?_编程10000问

如何编写一个过滤掉HTML代码的函数?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <%Function Filterhtml(strToFilter)  Dim strTemp  strTemp = strToFilter  While Instr(1,strTemp,"<") AND Instr(1, strTemp, "

ASP问答集_编程10000问

问:为什么我的记录集的RecordCount值总是返回-1? 答:你应当使用这种模式来打开存取数据库的记录集:   rec.open strSQL,conn,1,1   其中的strSQL是操作数据库的SQL语句;conn是联接数据库的Connection 变量. 问:我在ASP脚本中写了很多的注释,这会不会影响服务器处理ASP文件的速度? 答:经国外技术人员测试,带有过多注释的ASP文件整体性能仅仅会下降0.1%,也就是说基本上不会影响到服务器的性能下降的. 问:我需不需要在每个ASP文件的开

如何用ASP输出HTML文件?_编程10000问

<!--#include file="top.inc"--><%u_title=request.form("u_title")<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 检查标题是否被输入.if u_title = "" then%><form method="P