Method for generating an Excel file and an Excel.dll component generated by the Excel.dll component Select a Blog of WANG8712: Class Apptest {Private Excel.ApplicationClass_x; Public Static Void Main0 () {Apptest A = New Apptest (); A._X = New Excel.ApplicationClass (); a._x.userControl = false; for (int i = 0; i <4; i ) {a.savetoxls ("D: // Test //" i ".xls" ); // This example is the TEST folder established under D._x.quit (); system.Runtime.InteropServices.Marshal.ReleaseComobject (object) A._X); system.gc.collect () } Private void savetoxls (string filename) {Excel.WorkbookClass WB = (Excel.WorkbookClass) this._x.Workbooks.add (system.reflection.Missing.Value); for (int i = 1; i <= 4; i ) ) {This._x.cells [i, 1] = i.toString (); this._x.cells [i, 2] = "'bb2"; this._x.cells [i, 3] = "' ccc3" This._x.cells [i, 4] = "'aaa4";} wb.saved = true; this._x.activeworkbook.savecopyas (filename);}} [Note: running in vs.net is to add Excel The.dll component, the Excel component vs.net itself is not, the following is a method of generating Excel.dll. 】 1. To ensure that the machine itself should install Office. 2. Copy the Excel9.olb file under the [C: / Program Files / Microsoft Office / Office: Default Installation Path] to [C: / Visual Studio.net/SDK/v1 .1 / bin: VS.NET Installation Path: Path. 3. Open the Visual Studio .Net2003 command prompt, run TLBIMP Excel9.olb Excel.dll, generate an Excel.dll component in [C: / Visual Studio.net/SDK/v1.1/bin]. 4. Add an Excel.dll in the project to OK.