Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert xls to pdf
Im trying to use the code in attached the link:
http://msdn.microsoft.com/en-us/library/bb407651.aspx Microsoft.Office.Interop.Excel.ApplicationClass excelApplication = new Microsoft.Office.Interop.Excel.ApplicationClass(); Workbook excelWorkBook = null; string paramSourceBookPath = @"C:\Temp\Test.xlsx"; object paramMissing = Type.Missing; string paramExportFilePath = @"C:\Temp\Test.pdf"; XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF; XlFixedFormatQuality paramExportQuality =XlFixedFormatQuality.xlQualityStandard; bool paramOpenAfterPublish = false; bool paramIncludeDocProps = true; bool paramIgnorePrintAreas = true; object paramFromPage = Type.Missing; object paramToPage = Type.Missing; try { // Open the source workbook. excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPat h, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing); // Save it in the target format. if (excelWorkBook != null) excelWorkBook.ExportAsFixedFormat(paramExportForma t, paramExportFilePath, paramExportQuality, paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage, paramToPage, paramOpenAfterPublish, paramMissing); } catch (Exception exc) { // Respond to the error. } finally { // Close the workbook object. if (excelWorkBook != null) { excelWorkBook.Close(false, paramMissing, paramMissing); excelWorkBook = null; } // Quit Excel and release the ApplicationClass object. if (excelApplication != null) { excelApplication.Quit(); excelApplication = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } It works fine except for the process that is created but not closed after the operation is done. What else is missing? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert xls to pdf
Never used code like yours but take a look here
http://www.rondebruin.nl/pdf.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Avishay Ben-Zvi" wrote in message ... Im trying to use the code in attached the link: http://msdn.microsoft.com/en-us/library/bb407651.aspx Microsoft.Office.Interop.Excel.ApplicationClass excelApplication = new Microsoft.Office.Interop.Excel.ApplicationClass(); Workbook excelWorkBook = null; string paramSourceBookPath = @"C:\Temp\Test.xlsx"; object paramMissing = Type.Missing; string paramExportFilePath = @"C:\Temp\Test.pdf"; XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF; XlFixedFormatQuality paramExportQuality =XlFixedFormatQuality.xlQualityStandard; bool paramOpenAfterPublish = false; bool paramIncludeDocProps = true; bool paramIgnorePrintAreas = true; object paramFromPage = Type.Missing; object paramToPage = Type.Missing; try { // Open the source workbook. excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPat h, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing); // Save it in the target format. if (excelWorkBook != null) excelWorkBook.ExportAsFixedFormat(paramExportForma t, paramExportFilePath, paramExportQuality, paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage, paramToPage, paramOpenAfterPublish, paramMissing); } catch (Exception exc) { // Respond to the error. } finally { // Close the workbook object. if (excelWorkBook != null) { excelWorkBook.Close(false, paramMissing, paramMissing); excelWorkBook = null; } // Quit Excel and release the ApplicationClass object. if (excelApplication != null) { excelApplication.Quit(); excelApplication = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } It works fine except for the process that is created but not closed after the operation is done. What else is missing? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
can the "convert" function in excel convert to UK gallons? | Excel Discussion (Misc queries) | |||
Convert Columns of Sensitive Information, and then convert back... | Excel Programming | |||
convert decimal number to time : convert 1,59 (minutes, dec) to m | Excel Discussion (Misc queries) | |||
Convert Time...!convert tenths of a second | Excel Discussion (Misc queries) |