Execel文件插入到ASP页面
网络整理 - 09-16
<%Set Xlapp=Server.Createobject("Execel.Application")
Xlapp.Visible=false
'使服务端不出现Execel窗口
Set myWorkbook=xlapp.Wordbooks.Add
Set myWorksheet=myWorkbook.Worksheets(1)
'建立一个WorkSheet
myWorkSheet.Range("A1").Value=''
myWorkSheet.Range("A1").Vont.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(strAppPth,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
'发到浏览器中去
%>