C#我打开excel表,然后用微软自带库读取excel表格到datagridview后,此时excel表无法编辑,好像处于锁定状态,无法关闭,只有关了程序才能进行编辑,如何用代码解决

我读取表格用的是微软自带库,如何解决
读取完excel表格内容后,用的是
private Excel.Application excel1;
private Excel.Workbooks wbs = null;
private Excel.Workbook wb = null;
private Excel.Sheets wss;
private Excel.Worksheet ws = null;
private Excel.Range range1 = null;
excel1.Quit();

[DllImport("User32.dll")] 
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId);   
public static void KillExcelApp(this excel.Application app) {
    app.Quit();
    IntPtr intptr = new IntPtr(app.Hwnd);
    int id;
    GetWindowThreadProcessId(intptr, out id);
    var p = Process.GetProcessById(id);
    if (p != null)
    p.Kill();
}

读完文件要关闭

dll和excel不能同时操作同一个文件,dll要及时关闭释放资源。

wb.close
或者
for each tmpwb in wbs
tmpwb.close
然后执行
excel1.Quit();

在读取前,用代码复制出一个副本,然后使用代码打开并读取该副本的数据即可。
我这里有个资源,就是使用微软的DCOM进行Excel操作的,里面有很丰富的函数,可以直接使用。
https://download.csdn.net/download/hyjchina/15621698?spm=1001.2014.3001.5503