<%
set xlApp = Server.CreateObject("Excel.Application")
xlApp.Visible = false

' 使服务端不出现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]

标签:
|如何|何把|把一|一个|个E|Ex|xc|ce|el|l文|文件|件放|放到|到A|AS|SP|P页|页面|面中|中去|去?|?|

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“如何把一个Excel文件放到ASP页面中去?”

暂无“如何把一个Excel文件放到ASP页面中去?”评论...