How to terminate C# based Excel Application instance?

前端 未结 2 760
盖世英雄少女心
盖世英雄少女心 2021-01-24 19:47

I\'m working on a small code to read some Excel files. I\'ve linked the COM library for Excel 15, and am using the following code to read Excel files:

excelInsta         


        
2条回答
  •  灰色年华
    2021-01-24 20:27

    As per the MSDN documentation here, use the Quit() method to close your instance, as such:

    var excelInstance = new Microsoft.Office.Interop.Excel.Application()
    
    // Do stuff
    
    excelInstance.Quit();
    

提交回复
热议问题