ASP operation Excel

xiaoxiao2021-03-18  231

Directory First, Environment Configuration 2, ASP's basic operations of Excel 3, ASP operation Excel generates data table four, ASP operation Excel generates Chart Figure 5, server-side Excel file browsing, download, delete Scenarius, appendix body 1, environment configuration server The side environmental configuration is on the reference, and the configuration of 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 saved, the page is wrong.

6, exit Excel Operation Objexcelapp.quit must exit set objectExcelapp = Nothing 3, ASP operation Excel generates data table 1, insert data Objexcelsheet.Range within a range ("b3: k3"). Value = array ("67" , "87", "5", "9", "7", "45", "45", "54", "54", "10") 2, inserted data Objexcelsheet.cells in a cell. 3, 1) .Value = "Internet Explorer" 3, select one range 4, the left painted thick line 5 left, the unit grid is the thick line 6, the cells are painted on the cell 7, the cells can be used at the lower edge 8, the cell setting Background color 9, merge cell 10, insert line 11, insert column four, ASP operation Excel generates Chart Figure 1, create a chart diagram Objexcelapp.Charts.add 2, set Chart map Objexcelapp.activechart.ChartType = 97 Note: Two Main drawing diagram, 4; two-dimensional cake diagram, 5; two-dimensional column, 51 3, set Chart figure title Objexcelapp.activechart.hastitle = true objexcelapp.actiVhart.Charttitle.Text = "a test chart" 4, pass through graphics table data setting objExcelApp.ActiveChart.SetSourceData objExcelSheet.Range ( "A1: k5"), 1 5, graphical data set directly (recommended) objExcelApp.ActiveChart.SeriesCollection.NewSeries objExcelApp.ActiveChart.SeriesCollection (1) .Name = "=" "333" "" Objexcelapp.activeChart.seriesCollection (1) .values ​​= "= {1, 4, 5, 6, 2}" 6, binding Chart Objexcelapp.ActiveChart.Location 1 7, display data table Objexcelapp.activechart.hasDataTa BLE = TRUE 8, display legend Objexcelapp.activeChart.DataTable.showlegendKey = true 5, server-side Excel file browsing, download, deleting solution browsing solutions, "location.href =", "navigate", "response.redirect" It can be implemented, recommended for the client's approach, because the excel file is generated for more time. 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.

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

New Post(0)