I. There are two methods to solve the operation permission problem:
1. Use a simulated account and add it to the Web. config file.
- <!identity impersonate="true" userName="administrator" password=""/>
2. In the DCOM component service, grant the ASP. NET Operation permission to the MICROSOFT. EXCEL component. The procedure is as follows:
1) Open the run dialog box of the Start Menu, enter the dcomcnfg command, and click OK. The component service window is displayed.
2) expand computer> my computer> DCOM, and find the Microsoft Excel application node.
3) Right-click-> properties, select the "Security" option, select "Custom" for each of the following three projects, and click the edit button.
4) Click the Add button in the launch permission dialog box to add corresponding users. Note: if it is WIN2000 or XP, add the "machine name/ASPNET" user. Here we use WIN2003 as an example, WIN2003 is used to add a "NETWORK Service" user) and grant the maximum permission to the user.
Ii. ASP. NET end the Excel Process
1. In the previous article, I used ASP to determine the process startup time. NET to end the Excel process, although it seems a bit inappropriate, but I have never encountered any problems, never mistakenly killed other Excel processes.
2. Release the resources of all used Excel objects. Copy a piece of code here:
- Objectmissing=System. Reflection. Missing. Value;
- Microsoft. Office. Interop. Excel. ApplicationmyExcel=NewMicrosoft. Office.
Interop. Excel. ApplicationClass ();
- MyExcel. Visible=False;
- // Open a new file
- Microsoft. Office. Interop. Excel. WorkbooksmyBooks=MyExcel. Workbooks;
- Microsoft. Office. Interop. Excel. WorkbookmyBook=MyBooks.
Open (sourceFile, missing ,...);
- Microsoft. Office. Interop. Excel. WorksheetcurSheet=
(Microsoft. Office. Interop. Excel. Worksheet) myBook. ActiveSheet;
-
- Microsoft. Office. Interop. Excel. Rangerans=
(Microsoft. Office. Interop. Excel. Range) curSheet. Cells;
- Microsoft. Office. Interop. Excel. Rangeran=Null;
- Microsoft. Office. Interop. Excel. RangeranMerge=Null;
- Microsoft. Office. Interop. Excel. RangeranRows=Null;
- Microsoft. Office. Interop. Excel. RangeranCells=Null;
- For (Inti=0; I<10; I ++)
- {
- For (Intj=0; J<10; J ++)
- {
- Ran= (Microsoft. Office. Interop. Excel. Range) rans [I + 1, j + 1];
-
- RanRanMerge= Ran. MergeArea;
- RanRows=RanMerge. Rows;
- IntmergeRows=RanRows. Count;
- RanCells=RanMerge. Cells;
- IntmergeCells=RanCells. Count;
- Response. Write ("<Br/>"+ I +": "+ j +": "+ ran. Text );
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (ranCells );
- RanCells=Null;
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (ranRows );
- RanRows=Null;
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (ranMerge );
- RanMerge=Null;
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (ran );
- Ran=Null;
- }
- }
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (rans );
- Rans=Null;
-
- System. Runtime. InteropServices. Marshal. ReleaseComObject (curSheet );
- CurSheet=Null;
-
- MyBook. Close (false, Type. Missing, Type. Missing );
- System. Runtime. InteropServices. Marshal. ReleaseComObject (myBook );
- MyBook=Null;
-
- MyBooks. Close ();
- System. Runtime. InteropServices. Marshal. ReleaseComObject (myBooks );
- MyBooks=Null;
-
- MyExcel. Quit ();
- System. Runtime. InteropServices. Marshal. ReleaseComObject (myExcel );
- MyExcel=Null;
-
- GC. Collect ();
- GC. WaitForPendingFinalizers ();
These two problems are summarized for the time being. These solutions come from the Internet. Here I will just summarize them. By the way, I will download some Excel controls I have collected for you:
Http://files.cnblogs.com/lingyun_k/ExcelWriter.rar
This is cracked.
Http://files.cnblogs.com/lingyun_k/Aspose%20Excel%20V2.3.1.1.NET.rar
Another one is ExcelQuicker, which has strong functions. You can find it after searching. However, I think the golden printing King is more convenient than Excel, but does not support WebForm, the above introduces ASP. NET ends the Excel Process
- Analysis of Theme functions in ASP. NET development skills
- ASP. NET Dynamic Compilation
- Analysis on ASP. NET supported by Apache
- Introduction to ASP. NET Server standard controls
- Analysis on SQL Server Database Backup Recovery in ASP. NET