How can I put an Excel file on an ASP page?

Source: Internet
Author: User

<%
Set xlApp = Server. CreateObject ("Excel. Application ")
XlApp. Visible = false

'Disable ServerExcelWindow.
Set myWorkbook = xlApp. Workbooks. Add

'CreateWorksheet.
Set myWorksheet = myWorkbook. Worksheets (1)
MyWorksheet. Range ("A1"). Value ='Brilliant spring breeze address book'
MyWorksheet. Range ("A1"). Font. Size = 12
MyWorksheet. Range ("A1"). Font. Bold = true
MyWorksheet. Range ("A2"). Value ='Name'
MyWorksheet. Range ("B2"). Value ='Address'
MyWorksheet. Range ("C2"). Value ='Phone number'
MyWorksheet. Range ("D2"). Value ='Mobile phone'

'Above7Create a header for a row.
MyWorksheet. Range ("A2: D2"). Font. Bold = true
StrFileName = Session. SessionID & ". xls"

'Ensure the file name is unique.
StrAppPath = Request. ServerVariables ("PATH_trANSLATED ")
StrAppPath = Left (strAppPath, limit Rev (strAppPath ,"\"))
StrFullPath = strAppPath & strFileName
MyWorkbook. SaveAs (strFullPath)

'Save files.
MyWorkbook. Close

'CloseExcel.
XlApp. Quit
Set myWorksheet = Nothing
Set myWorkbook = Nothing
Set myxlApp = Nothing
Response. Redirect strFileName

' Write ASP Page , In the browser .
%>

[1]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.