Execel文件插入到ASP页面
2001-11-18 11:06:44 来源:WEB开发网核心提示:<%Set Xlapp=Server.Createobject("Execel.application")Xlapp.Visible=false'使服务端不出现Execel窗口Set myWorkbook=xlapp.Wordbooks.AddSet myWorksheet=myWor
<%
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
'发到浏览器中去
%>
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
'发到浏览器中去
%>
更多精彩
赞助商链接