当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Excel.Quit方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Excel.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Excel.Quit方法的具体用法?C# Microsoft.Office.Interop.Excel.Quit怎么用?C# Microsoft.Office.Interop.Excel.Quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Excel的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Excel.Quit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloseExcel

 // closes Excel
 public static void CloseExcel(Excel.Application xlApp, Excel.Workbook wb)
 {
     // Close Excel
     object misValue = System.Reflection.Missing.Value;
     wb.Close(false, misValue, misValue);
     xlApp.Quit();
 }
开发者ID:jcollins1007,项目名称:xlScraper,代码行数:8,代码来源:xlScraper.cs

示例2: ReleaseExcel

        protected void ReleaseExcel(ref MSOffice.Application excelApp, ref MSOffice.Workbook excelBook, ref MSOffice.Worksheet excelSheet)
        {
            try
            {
                excelBook.Close(false, null, null);
                excelApp.Quit();
                GC.Collect();

                IntPtr ptr = new IntPtr(excelApp.Hwnd);
                int pid = 0;
                GetWindowThreadProcessId(ptr, out pid);
                System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcessById(pid);

                System.Runtime.InteropServices.Marshal.ReleaseComObject((object)excelApp);
                System.Runtime.InteropServices.Marshal.ReleaseComObject((object)excelBook);
                System.Runtime.InteropServices.Marshal.ReleaseComObject((object)excelSheet);
                excelApp = null;
                excelBook = null;
                excelSheet = null;

                //最后尝试结束进程,出错表示已销毁
                try
                { proc.Kill(); }
                catch (Exception) { }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:chanfengsr,项目名称:AllPrivateProject,代码行数:30,代码来源:OfficeInfo.cs

示例3: Dispose

        /// <summary>
        /// 释放内存
        /// </summary>
        public void Dispose(Excel._Worksheet CurSheet, Excel._Workbook CurBook, Excel._Application CurExcel)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(CurSheet);
                CurSheet = null;
                CurBook.Close(false, mValue, mValue);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(CurBook);
                CurBook = null;

                CurExcel.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(CurExcel);
                CurExcel = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (System.Exception)
            {
                // Response.Write("在释放Excel内存空间时发生了一个错误:" + ex);
            }
            finally
            {
                foreach (System.Diagnostics.Process pro in System.Diagnostics.Process.GetProcessesByName("Excel"))
                    //if (pro.StartTime < DateTime.Now)
                    pro.Kill();
            }
            System.GC.SuppressFinalize(this);
        }
开发者ID:refinedKing,项目名称:WeiXin--Vs2010-,代码行数:32,代码来源:ExcelOperate.cs

示例4: CloseAndReleaseExcelObjects

 private static void CloseAndReleaseExcelObjects(Excel.Application xlApp, Excel.Workbook xlworkBook, Excel.Worksheet xlWorksheet)
 {
     xlworkBook.Close(false, null, null);
     xlApp.Quit();
     ReleaseObject(xlWorksheet);
     ReleaseObject(xlworkBook);
     ReleaseObject(xlApp);
 }
开发者ID:malcolmcarvalho,项目名称:TrimCurve,代码行数:8,代码来源:ExcelFileDataExtractor.cs

示例5: ExcelDispose

        /// <summary>
        /// 저장및 메모리 해제
        /// </summary>
        /// <param name="excelApp"></param>
        /// <param name="wb"></param>
        /// <param name="workSheet"></param>
        public static void ExcelDispose(Excel.Application excelApp, Excel.Workbook wb, Excel._Worksheet workSheet)
        {
            wb.SaveAs(@"C:\users\user\Desktop\수강신청시간표", Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            wb.Close(Type.Missing, Type.Missing, Type.Missing);
            excelApp.Quit();
            releaseObject(excelApp);
            releaseObject(workSheet);
            releaseObject(wb);
        }
开发者ID:XavierKim,项目名称:TimeTable,代码行数:17,代码来源:TimeTable.cs

示例6: release_excel_app

 private void release_excel_app(ref MSExcel.Application excelApp)
 {
     excelApp.Workbooks[1].Close();
     excelApp.Quit();
     if (excelApp != null)
     {
         int lpdwProcessID;
         GetWindowThreadProcessId(new IntPtr(excelApp.Hwnd), out lpdwProcessID);
         System.Diagnostics.Process.GetProcessById(lpdwProcessID).Kill();
     }
 }
开发者ID:zhang3310028,项目名称:PrimerDimerTool,代码行数:11,代码来源:Form1.cs

示例7: ExcelQuit

        /// <summary>
        /// Close Excel workbook, quit excel and wait until finished
        /// </summary>
        /// <param name="app">Excel handle to quit</param>
        /// <param name="wb">Excel workbook to close</param>
        private static void ExcelQuit(Excel.Application app, Excel.Workbook wb)
        {
            wb.Close(SaveChanges: false);
            app.Quit();
            while (Marshal.ReleaseComObject(app) != 0)
            {
            }

            app = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
开发者ID:kohlmann0,项目名称:Resx2Xls,代码行数:17,代码来源:ResxData.cs

示例8: SaveExcel

        private void SaveExcel(string file, MSExcel.Application excel, MSExcel.Workbook wbook)
        {
            try
            {
                File.Delete(file);
            }
            catch //(Exception ex)
            {
                wbook.Close(false);

                excel.Quit();

                return;
            }

            try
            {
                wbook.SaveAs(file, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSExcel.XlSaveAsAccessMode.xlExclusive);
            }
            catch//(Exception ex)
            {

            }

            wbook.Close(false);

            excel.Quit();
        }
开发者ID:W8023Y2014,项目名称:jsion,代码行数:28,代码来源:Form1.cs

示例9: ConvertToXlsx

        public static string ConvertToXlsx(string filePath, Excel.Application excel = null)
        {
            excel = excel ?? CreateExcel();

            var workbook = excel.Workbooks.Open(filePath, UpdateLinks: false, ReadOnly: true);
        	
        	var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
     
        	workbook.SaveAs(path, FileFormat: Excel.XlFileFormat.xlOpenXMLWorkbook, 
        	                AccessMode: Excel.XlSaveAsAccessMode.xlNoChange);
        	
        	workbook.Close(false);
        	excel.Quit();
        	
        	return path;
        }
开发者ID:markovcd,项目名称:Mapper,代码行数:16,代码来源:ExcelHelper.cs


注:本文中的Microsoft.Office.Interop.Excel.Quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。