Recommended: How to use the Asp program to read the website's Alexa world rankings Whenever Alexa ranking is updated, I need to sort out the rankings of all related similar websites and see the ranking updates of these rival websites. I have done more, and I feel annoyed. Although I have only more than 30 websites, I feel a little tired after watching them one by one. Therefore, I want
One way to use excel in Asp is to link the excel file as a database, and the operation is similar to the access database operation. But this method is not always useful, it should be that excel is not a relational database. For a fixed format, this format contains complex cell merging, border line styles, patterns, formula relationships between cells, etc. I think the easiest thing to understand is to open a file with already set templates in the background, and then insert data where needed, save, and output...
The method mentioned here is to directly create an excel object, which can perform various operations on the excel document more conveniently in the background.
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 Properties button. Select all three single options to customize. Add Everyone to all permissions during editing. Restart the server after saving.
It is very important. If you don't set it up, other computers will not be able to complete the establishment of the excel object.
However, this method also has a drawback. In my actual operation, if there is an open excel file on the server and the same file is executed, an error will occur. I still don’t understand why. There may be some places that have not been set up properly.
In addition, the example code format in the article quoted above is not very complete, and many of the line breaks and spaces are inaccurate. If the code is complete, just copy the code and run it successfully. Then slowly research and modify it, it will be easy to get started. Now the modified code is as follows (the part where the chart is drawn is deleted):
| The following is the quoted content: <% On Error Resume Next strAddr=Server.MapPath(.) set objExcelApp=CreateObject(Excel.Application) objExcelApp.DisplayAlerts=false objExcelApp.Application.Visible=false objExcelApp.WorkBooks.Open(strAddr&/Templet/Null.xls) set objExcelBook=objExcelApp.ActiveWorkBook set objExcelSheets=objExcelBook.Worksheets set objExcelSheet=objExcelBook.Sheets(1) objExcelSheet.Range(B2:k2).Value=Array(Week1,Week2,Week3,Week4,Week5,Week6,Week7) objExcelSheet.Range(B3:k3).Value=Array(67,87,5,9,7,45,45,54,54,10) objExcelSheet.Range(B4:k4).Value=Array(10,10,8,27,33,37,50,54,10,10) objExcelSheet.Range(B5:k5).Value=Array(23,3,86,64,60,18,5,1,36,80) objExcelSheet.Cells(3,1).Value=InternetExplorer objExcelSheet.Cells(4,1).Value=Netscape objExcelSheet.Cells(5,1).Value=Other objExcelSheet.Range(b2:k5).Select SaveAs(strAddr&/Temp/Excel.xls) objExcelApp.Quit set objExcelApp=Nothing %> <!DOCTYPEHTMLPUBLIC-//W3C//DTDHTML4.0Transitional//EN> <HTML> <HEAD> <TITLE>NewDocument</TITLE> <METANAME=GeneratorCONTENT= MicrosoftFrontPage5.0> <METANAME=AuthorCONTENT=> <METANAME=KeywordsCONTENT=> <METANAME=DescriptionCONTENT=> </HEAD> <BODY> </BODY> </HTML> |
After operating the excel file, you need to output the file. In fact, use ASP's redirect to the excel method. Sometimes it is opened directly in IE, and sometimes it is a pop-up download and open a save window. If you need to open it directly in IE, use FSO to load the excel file, and then output it in IE.
The following is the quoted content: <% Dim Fso, FileExt, strFilePath, Mime strFilePath = f:/aspxuexi.doc Set Fso=Server.CreateObject(Scripting.FileSystemObject) FileExt = Fso.GetExtensionName(strFilePath) Set fso=Nothing Select Case FileExt Case doc Mime=Application/msword Case xls Mime=Application/msexcel End Select Call OutPut(strFilePath,Mime) '###################################################### Function OutPut(strFilePath,Mime) Response.ContentType = Mime Const adTypeBinary = 1 Set objStream = Server.CreateObject(ADODB.Stream) objStream.Open objStream.Type = adTypeBinary objStream.LoadFromFile strFilePath Response.BinaryWrite objStream.Read objStream.Close Set objStream = Nothing End Function '###################################################### %> |
In practical applications. When the server side is running excel or ACCESS program, the client submits to create excel. The application object cannot succeed. In another case, when one client submits a request and does not end, the request submitted by another client cannot succeed either! Maybe there are other solutions to this problem, but at least it is unstable.
It just so happened that there are related successful examples on the internal network of our department. I dug it out and found out that it was to build excel on the client. application. In this way, there will be no conflicts on the server side. For clients, because they are running on the LAN, the security level of the client IE can be set to be low and relevant activeX is allowed (that is, all kinds of security-related things are set to allow in the IE tool options, and which specific item is not investigated). Even if it is not set, IE will pop up a warning window: Is it allowed to run activeX?
Share: How to access multiple domain names in one website space A piece of ASP code that can enable access to multiple domain names in a website space: The following is the referenced content: %if Request.ServerVariables(SERVER_NAME)=&q
3 pages in total Previous page 123 Next page