插入|頁面 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
'發到瀏覽器中去
%>