I just used it, no problem. Excel.Application myExcel; Excel._Workbook myWB; Excel._Worksheet myWS = null; Excel.Range myRrange = null; try {myExcel = new Excel.ApplicationClass (); myWB = (Excel._Workbook) myExcel.Workbooks.Open (file. Fullname, Type.Missing, Type.Missing, Type.missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing Catch (Exception E) {e.tostring ();} int sheetnum = mywb.worksheets.count; if (SheetNum> 0) {for (int i = 1; i <= sheetnum; i ) {mYws = (Excel) ._Worksheet) MYWB.WORKSHEETS [I];
Int rownum = myws.used management; if (rownum> = 2) {for (int J = 2; j <= rower; j ) {myRrange = myws.get_range ("a" j.toString ), "E" j. Tostring ()); array myvalues = (array) MyRrange.cells.Value;}}}
// The following content can not be less! ! myWB.Close (false, Type.Missing, Type.Missing); myExcel.Workbooks.Close (); myExcel.Quit (); System.Runtime.InteropServices.Marshal.ReleaseComObject (myRrange); System.Runtime.InteropServices.Marshal. ReleaseComObject (myExcel); System.Runtime.InteropServices.Marshal.ReleaseComObject (myWS); System.Runtime.InteropServices.Marshal.ReleaseComObject (myWB); myWS = null; myWB = null; myExcel = null; GC.Collect ();