Execel文件插入到ASP页面 <%
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
'发到浏览器中去
%>