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


C# Application.ReleaseComObject方法代码示例

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


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

示例1: Generate

        public string Generate(string targetDir, List<DhlWaybillParam> dhlWaybillParamList)
        {
            string ExcelFile = this.resourceReleaser.ReleaseXls("ZD_Bpost_Template", targetDir);

            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;
            xlApp = new Excel.Application();
            int realRowIndex = 6;

            xlWorkBook = xlApp.Workbooks.Open(ExcelFile);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            foreach (var info_xls_Pre in dhlWaybillParamList)
            {
                FillXlWorkSheet(xlWorkSheet, realRowIndex, info_xls_Pre);

                if (OnReportStep != null)
                {
                    OnReportStep(0.0f);
                }
                realRowIndex++;
            }

            FileInfo fileInfo = new FileInfo(ExcelFile);
            string newfileName = GetFileName(dhlWaybillParamList);

            string newFullFileName = Path.Combine(fileInfo.Directory.FullName, newfileName);
            xlWorkBook.SaveAs(newFullFileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            xlWorkSheet.ReleaseComObject();
            xlWorkBook.ReleaseComObject();
            xlApp.ReleaseComObject();

            File.Delete(ExcelFile);

            return newFullFileName;
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:41,代码来源:ZdBpostWaybillExcelBuilder.cs

示例2: PrintXlsFile

        private void PrintXlsFile(string filePath)
        {
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;
            xlApp = new Excel.Application();


            xlWorkBook = xlApp.Workbooks.Open(filePath);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            xlWorkBook.PrintOutEx();

            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            xlWorkSheet.ReleaseComObject();
            xlWorkBook.ReleaseComObject();
            xlApp.ReleaseComObject();
        
        
        }
开发者ID:cotopboy,项目名称:nxdaigou_git,代码行数:23,代码来源:PrintService.cs


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