Type.Missing, Type.Missing, Type.Missing,
Type.Missing, false);
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
if (mWSheet != null) mWSheet = null;
if (mWorkBook != null) mWorkBook.Close(Type.Missing, Type.Missing, Type.Missing);
if (mWorkBook != null) mWorkBook = null;
if (oXL != null) oXL.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL);
if (oXL != null) oXL = null;
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
}
}
需要特别指出的是:需要在项目中添加 Microsoft.Office.Interop.Excel.dll 文件,具体操作:选中引用->右键添加引用->浏览找到 Microsoft.Office.Interop.Excel,添加引用。










