复制了部分代码,供你参考:
Excel.Application excelApp = null;
Excel.Workbook excelWorkbook = null;
string workbookPath=‘’;//excel文件名字
 excelApp = new Excel.ApplicationClass();
  excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
                     false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); string currentSheet = "";//sheet页名字
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelWorkbook.Sheets.get_Item(currentSheet);
 Excel.Range excelCell1 = (Excel.Range)excelWorksheet.get_Range("A3", "A3");
 excelCell1.Cells[1, 1] ="testString";                    Marshal.ReleaseComObject(excelCell1);                    excelCell1 = null;                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                if (excelWorkbook != null)
                {
                    excelWorkbook.Close(true, Type.Missing, Type.Missing);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook);
                    excelWorkbook = null;
                }                if (excelWorkbook != null)
                {
                    excelWorkbook.Close(false, Type.Missing, Type.Missing);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook);
                    excelWorkbook = null;
                }
                if (excelApp != null && excelApp.Workbooks.Count < 1)
                {
                    excelApp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                    excelApp = null;
                }
                GC.WaitForPendingFinalizers();
                GC.Collect();