I. Excel operation permission problems:
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 Start Menu running dialog box and enter Dcomcnfg Command, OK, the component service window will pop up
(2) expand computer> my computer> DCOM, and find the Microsoft Excel application.ProgramNode
(3) Right-click-> properties, select the "Security" option, select "Custom" for each of the following three projects, and click the edit button.
(4) In the "Start permission" dialog box, click the Add button to add the corresponding user (Note: if it is Win2000 or XP, add "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.
Ii. End the Excel Process
1. I used the previous article to judge the process start time to end the Excel process. Although it seems a bit inappropriate, I have never encountered any problems when using it and have never mistakenly killed other Excel processes.
2. Release the resources of all used Excel objects. Copy a section here.Code:
This Code comes from: http://community.csdn.net/Expert/topic/3486/3486601.xml? Temp = 2.860659e-02
Object Missing = System. reflection. Missing. value;
Microsoft. Office. InterOP. Excel. Application myexcel = New Microsoft. Office. InterOP. Excel. applicationclass ();
Myexcel. Visible = False ;
// Open New File
Microsoft. Office. InterOP. Excel. workbooks mybooks = Myexcel. workbooks;
Microsoft. Office. InterOP. Excel. Workbook mybook = Mybooks. Open (sourcefile, missing, and missing );
Microsoft. Office. InterOP. Excel. worksheet cursheet = (Microsoft. Office. InterOP. Excel. worksheet) mybook. activesheet;
Microsoft. Office. InterOP. Excel. Range RANS = (Microsoft. Office. InterOP. Excel. Range) cursheet. cells;
Microsoft. Office. InterOP. Excel. Range ran = Null ;
Microsoft. Office. InterOP. Excel. Range ranmerge = Null ;
Microsoft. Office. InterOP. Excel. Range ranrows = Null ;
Microsoft. Office. InterOP. Excel. Range rancells = Null ;
For ( Int I = 0 ; I < 10 ; I ++ )
{
For ( Int J = 0 ; J < 10 ; J ++ )
{
Ran = (Microsoft. Office. InterOP. Excel. Range) RANS [I + 1 , J + 1 ];
Ranmerge = Ran. mergearea;
Ranrows = Ranmerge. Rows;
Int Mergerows = Ranrows. count;
Rancells = Ranmerge. cells;
Int Mergecells = 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.