■ 엑셀(EXCEL.exe) 제거하기

----------------------------------------------------------------------------------------------------

using System.Runtime.InteropServices;

 

using Excel = Microsoft.Office.Interop.Excel;

 

...

 

Excel.Application excelApplication = new Excel.Application();

Excel.Workbooks   excelWorkbooks   = excelApplication.Workbooks;

Excel.Workbook    excelWorkbook    = excelWorkbooks.Add("");

Excel.Sheets      excelSheets      = excelWorkbook.Worksheets;

Excel.Worksheet   excelSheet       = excelSheets["Sheet1"] as Excel.Worksheet;

Excel.Range       excelRange       = excelSheet.Cells as Excel.Range;

Excel.Range       excelA1Range     = excelRange.get_Item("1", "A") as Excel.Range;

 

excelA1Range.Value2 = "Hello EXCEL Interop";

 

...

 

excelApplication.DisplayAlerts = false;

 

excelApplication.Quit();

 

Marshal.ReleaseComObject(excelA1Range    );

Marshal.ReleaseComObject(excelRange      );

Marshal.ReleaseComObject(excelSheet      );

Marshal.ReleaseComObject(excelSheets     );

Marshal.ReleaseComObject(excelWorkbook   );

Marshal.ReleaseComObject(excelWorkbooks  );

Marshal.ReleaseComObject(excelApplication);

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요