本文整理汇总了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;
}
示例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();
}