盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

在ASP页面中插入excel文件(转)

时间:2024/11/8作者:未知来源:盾怪网教程人气:

[摘要]<%set xlApp = Server.CreateObject("Excel.Application")'使服务端不出现Excel窗口xlApp.Visible...

<%
set xlApp = Server.CreateObject("Excel.Application")
'使服务端不出现Excel窗口
xlApp.Visible = false
'建立一个worksheet
set myWorkbook = xlApp.Workbooks.Add
set myWorksheet = myWorkbook.Worksheets(1)
'建立表头
myWorksheet.Range("A1").Value = '电话薄'
myWorksheet.Range("A1").Font.Size = 18
myWorksheet.Range("A1").Font.Bold = true
myWorksheet.Range("A2").Value = '姓名'
myWorksheet.Range("B2").Value = '住址'
myWorksheet.Range("C2").Value = '电话'
myWorksheet.Range("D2").Value = '传真'
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)
'关闭Excel
myWorkbook.Close
xlApp.Quit
set myWorksheet = Nothing
set myWorkbook = Nothing
set myxlApp = Nothing
'写出到浏览器中
Response.Redirect strFileName
%>


关键词:在ASP页面中插入excel文件(转)




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版