ASP operation Excel technology summary

xiaoxiao2021-03-06  54

ASP Operation Excel Technical Summary Directory First, Environment Configuration II, ASP EXCEL's Basic Action 3, ASP Operation Excel Generates Data Table 4, ASP Operation Excel Generates Chart Figure 5, Server EXCEL File Browse, Download, Delete Scenary, Appendix

Text 1. Environment Configuration Server-side Environment Configuration Views on the reference, the Microsoft series should be all line, namely: 1. Win9X PWS Office 2. Win2000 Professional PWS Office 3. Win2000 Server IIS Office is currently the successful environment of the author. The version of Office does not have special requirements, take into account the uncertainty and compatibility features of client configuration, and it is recommended that the server-side Office version should not be too high to prevent the client from being downloaded after downloading. The server-side environment configuration has two accidental discovery: 1. The author develops the machine's original WPS2002, and the results of the Excel object have always been issued, and after uninstalling the WPS2002, the error disappears. 2. The author develops ASP code likes to use FrontPage, and the results are found to find that if the FrontPage is open (server-side), the object creates unstable phenomenon, and it is time to succeed. After the expansion, found that the Office series software is running in the server side, and the creation of the Excel object is difficult to succeed. The server side must also set is the operation permission of the COM component. Type "DCMCNFG" on the command line, enter the COM component configuration interface. After selecting Microsoft Excel, click the Properties button to select a custom, and the EVERYONE is added to all permissions. Restart the server after saving. The client's environmental configuration did not find anything particularly parallel, as long as office and IE can be installed, the version is generally like.

Two, ASP basic operation of Excel 1, the Excel object the establishment set objExcelApp = CreateObject ( "Excel.Application") objExcelApp.DisplayAlerts = false does not display a warning objExcelApp.Application.Visible = false display interface 2, the new Excel file objExcelApp.WorkBooks .add set objExcelBook = objExcelApp.ActiveWorkBook set objExcelSheets = objExcelBook.Worksheets set objExcelSheet = objExcelBook.Sheets (1) 3, has read Excel files strAddr = Server.MapPath ( ".") objExcelApp.WorkBooks.Open (strAddr & " /Templet/Table.xls ") set objExcelBook = objExcelApp.ActiveWorkBook set objExcelSheets = objExcelBook.Worksheets set objExcelSheet = objExcelBook.Sheets (1) 4, save Excel file objExcelBook.SaveAs strAddr &" /Temp/Table.xls "5, save Excel file ObjexcelBook.save (the author is successful, page error.) 6. Exit Excel Operation Objexcelapp.quit must exit Set Objexcelapp = Nothing 3, ASP Operation Excel Generate Data Table 1, Insert Data Objexcelsheet in a range ("B3: K3"). Value = array ("67", "87", "5", "9", "7", "45", "45", "54", "54", "10 ") 2, insert data Objexcelsheet.cells (3, 1) .Value =" Internet Explorer "3, select a range 4, and the cells of the cell 5, single The thick line 6 is painted on the right side 6, the cells are painted on the cell 7, the cells are drawn at the lower edge 8, the cell setting background color 9, the combined unit 10, insert line 11, insert column

Fourth, ASP Operation Excel Generates Chart Figure 1, Create a Chart Illustration Objexcelapp.Charts.Add 2, Set Chart Diapp.ActiveChart.ChartType = 97 Note: Two-dimensional Pacing Map, 4; Diviscuits, 5; 2D Column, 513, FIG Chart title set objExcelApp.ActiveChart.HasTitle = True objExcelApp.ActiveChart.ChartTitle.Text = "A test Chart" 4, by setting the graphics table data objExcelApp.ActiveChart.SetSourceData objExcelSheet.Range ( " A1: K5 "), 1 5, Direct Settings Data (Recommended) Objexcelapp.ActiveChart.seriesCollection.newseries Objexcelapp.ActiveChart.seriesCollection (1) .name =" = "" 333 "" "Objexcelapp.activechart.seriesCollection (1 ) .Values ​​= "= {1, 4, 5, 6, 2}" 6, binding the chart Objexcelapp.activeChart.Location 1 7, display the data table Objexcelapp.activeChart.hasDataTable = True 8, display the legend Objexcelapp.activeChart. DataTable.showlegendkey = True 5, server-side Excel file browsing, download, deleting scenarios, "location.href =", "navigate", "response.redirect" can be implemented, recommended client methods, reasons It is a more time to generate an Excel file for the server. The implementation of the download is troublesome. Downloading components on an online homeD server or custom development a component is a better solution. Another method is to operate the Excel component at the client, and save the server-side EXCEL file to the client. This approach requires the client to open an operation permission of unsafe ActiveX controls, considering that each customer sets the server set to trusted sites, it is more expensive to use the first method. The delete scheme consists of three parts: A: The excel file generated by the same user is confident that the user ID number or sessionID number can be confidently not repeated string with the same file name, file name. This automatically overrides the previous file when the new file is generated. B: Set the SESSION_ONEND event in the global.asa file to delete the user's Excel temporary file. C: When setting the Application_onstart event in the global.asa file, delete all the files in the temporary directory. Note: Recommended Directory Structure / SRC Code / Templet Template Directory / TEMP Temporary Directory

6. The death process of Excel appears in the event of an error in the appendix is ​​a very headache. Plus "On Error Resume next" before each file will help improve this, because it will execute it to "Application.quit" regardless of whether the file generates an error, guarantees that each program is not left process. .

转载请注明原文地址:https://www.9cbs.com/read-114804.html

New Post(0)