C\#com 을 이용 하여 excel 방출 프로 세 스 를 조작 하 는 해결 방법
System.Runtime.InteropServices.Marshal.ReleaseComObject(sheets);
System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet);
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
excelApp = null;
wbclass = null;
sheets = null;
worksheet = null;
range = null;
GC.Collect();
GC.WaitForPendingFinalizers();
석방 이 철저 하지 못 한 것 은 여전히 진행 과정 이 존재 한다.두 번 째
//
[DllImport("User32.dll")]
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId);
private static void KillExcel(Microsoft.Office.Interop.Excel.Application theApp)
{
int id = 0;
IntPtr intptr = new IntPtr(theApp.Hwnd);
System.Diagnostics.Process p = null;
try
{
GetWindowThreadProcessId(intptr, out id);
p = System.Diagnostics.Process.GetProcessById(id);
if (p != null)
{
p.Kill();
p.Dispose();
}
}
catch (Exception ex)
{
}
}
이 방법 이 좋 습 니 다.프로 세 스 를 닫 을 수 있 도록 해 봤 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Django 시트 업로드우리가 작업한 대부분의 프로젝트에는 일괄적으로 데이터를 업로드하는 기능이 필요했습니다. 우리는 항상 Excel 시트를 처리하고 각 열이 각 모델로 이동하는 다른 코드를 작성했습니다. 최신 프로젝트에서 우리는 그것을 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.