为什么build立PDF后Excel不closures?

我使用此代码将Excel文件转换为PDF。 问题是Excel进程并不紧密。 我错过了什么?

protected void Indexchanged_ConvertPDF(Object sender, EventArgs e) { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); xlApp.DisplayAlerts = false; xlApp.Visible = false; xlApp.ScreenUpdating = false; string path = CertificadosPresion.SelectedRow.Cells[0].Text; string CertName = CertificadosPresion.SelectedDataKey.Value.ToString(); Workbook xlWorkbook = xlApp.Workbooks.Open(path); xlWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, @"C:\pdf\" + SALESID.Text + "_CertPres.pdf", 0, false, true); xlWorkbook.Close(); xlApp.Quit(); xlApp = null; xlWorkbook = null; DisposeCOMObject(xlWorkbook); DisposeCOMObject(xlApp); } 

这可不像人们想象的那么容易。 有一篇不错的文章丢失了关于这个话题的一些话:

http://devcity.net/PrintArticle.aspx?ArticleID=239

但除此之外,我认为这个问题可能是数据访问后在C#中closuresExcel应用程序进程的副本。 您的问题有很多潜在的解决scheme。