Table of contents
1. Environment configuration
2. Basic operations of ASP on Excel
3. ASP operation Excel generates data tables
4. ASP operation Excel generates Chart diagrams
5. Server-side Excel file browsing, downloading, and deletion solutions
VI. Appendix
text
1. Environment configuration
From the reference data, the configuration of the Microsoft series should be all OK, that is:
1. Win9x+PWS+Office
2. Win2000Professional+PWS+Office
3. Win2000Server+IIS+Office
The current environment where the author successfully tested is the latter two. There are no special requirements for the Office version. Considering the uncertainty of client configuration and the backward compatibility characteristics, it is recommended that the server-side Office version should not be too high to prevent the client from displaying correctly after downloading.
There are two other accidental discoveries about server-side environment configuration:
1. The author originally installed Kingsoft's WPS2002 on the development machine, but there was always a problem with the creation of Excel object. After uninstalling WPS2002, the error disappeared.
2. The author likes to use FrontPage when developing ASP code, but found that if FrontPage is opened (server side), the object creation will be unstable, sometimes successful and sometimes unsuccessful. After an extended investigation, it was found that if the Office series software is running on the server side, it is difficult to create Excel objects successfully.
The server side also needs to set the operation permissions of COM components. Type "DCOMCNFG" on the command line and enter the COM component configuration interface. Select Microsoft Excel and click the property button. Select all three single options to customize. Add Everyone to all permissions during editing. Restart the server after saving.
I didn't find anything particularly particular about the environment configuration of the client. As long as it is installed with Office and IE, it seems that the version is universal.
2. Basic operations of ASP on Excel
1. Create Excel Objects
setobjExcelApp=CreateObject("Excel.Application")
objExcelApp.DisplayAlerts=false No warning is displayed
objExcelApp.Application.Visible=false does not display the interface
2. Create a new Excel file
objExcelApp.WorkBooks.add
setobjExcelBook=objExcelApp.ActiveWorkBook
setobjExcelSheets=objExcelBook.Worksheets
setobjExcelSheet=objExcelBook.Sheets(1)
3. Read existing Excel files
strAddr=Server.MapPath(".")
objExcelApp.WorkBooks.Open(strAddr&"/Templet/Table.xls")
setobjExcelBook=objExcelApp.ActiveWorkBook
setobjExcelSheets=objExcelBook.Worksheets
setobjExcelSheet=objExcelBook.Sheets(1)
4. Save Excel file
objExcelBook.SaveAstrAddr&"/Temp/Table.xls"
5. Save Excel file
objExcelBook.Save (The author saved successfully during the test, and the page reported an error.)
6. Exit Excel operation