//Application対象
                Excel.Application excelApp = null;
                //Workbooks対象
                Excel.Workbooks excelBooks = null;
                //Workbook対象
                Excel.Workbook excelBook = null;
                //Excel入力
                Excel.Worksheet excelSheet = null;

                //閉鎖します
                excelApp.DisplayAlerts = false;
                excelApp.AlertBeforeOverwriting = false;
                //清空excelSheet対象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet);
                excelSheet = null;
                //清空excelBook対象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelBook);
                excelBook = null;
                //清空excelApp対象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                excelApp = null;
                excelBooks.Close();
                //清空excelBooks対象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelBooks);
                excelBooks = null;
                //清空ごみ箱
                GC.Collect();

posted on 2008-03-12 19:59  人人人人人  阅读(535)  评论(1编辑  收藏  举报