zl程序教程

您现在的位置是:首页 >  工具

当前栏目

csharp: word or excel Convert to PDF

ExcelPDF to or word convert csharp
2023-09-11 14:19:13 时间
using Word = Microsoft.Office.Interop.Word; //12.0 word 2007 using Excel = Microsoft.Office.Interop.Excel;//12.0 excel 2007
using Word = Microsoft.Office.Interop.Word; //12.0 word 2007

using Excel = Microsoft.Office.Interop.Excel;//12.0 excel 2007


/// EXCEL文檔轉成PDF文檔 /// 參考 http://msdn.microsoft.com/en-us/library/bb256835%28v=office.12%29.aspx /// Open XML SDK 2.0 for Microsoft Office http://www.microsoft.com/en-us/download/details.aspx?id=5124 /// 塗聚文 20120907 /// /summary /// param name="infile" /param /// param name="outfile" /param public void ExportExcel2PDF(string infile, string outfile) object objOpt = Missing.Value; Excel.Application excelApp = null; excelApp = new Excel.Application(); excelApp.Workbooks.Open(infile, objOpt, objOpt, objOpt, objOpt, objOpt, true, objOpt, objOpt, true, objOpt, objOpt, objOpt, objOpt, objOpt); excelApp.ActiveWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, (object)outfile, objOpt, objOpt, objOpt, objOpt, objOpt, objOpt, objOpt); catch (Exception ex) throw ex; finally if (excelApp != null) excelApp.Quit(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); /// summary /// WORD文檔轉成PDF文檔 /// 參考 http://msdn.microsoft.com/en-us/library/bb256835%28v=office.12%29.aspx /// /// 塗聚文 20120907 /// /summary /// param name="infile" /param /// param name="outfile" /param public void ExportWord2PDF(string infile, string outfile) object objOpt = Missing.Value; object readOnly = true; object missing=Missing.Value; object file=(object)infile; object SavePDFFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; Word.WdExportFormat paramExportFormat = Word.WdExportFormat.wdExportFormatPDF; bool paramOpenAfterExport = false; Word.WdExportOptimizeFor paramExportOptimizeFor = Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint; Word.WdExportRange paramExportRange = Word.WdExportRange.wdExportAllDocument; int paramStartPage = 0; int paramEndPage = 0; Word.WdExportItem paramExportItem = Word.WdExportItem.wdExportDocumentContent; bool paramIncludeDocProps = true; bool paramKeepIRM = true; Word.WdExportCreateBookmarks paramCreateBookmarks = Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks; bool paramDocStructureTags = true; bool paramBitmapMissingFonts = true; bool paramUseISO19005_1 = false; Word.Application wordApp = null; wordApp = new Word.Application(); wordApp.Documents.Open(ref file, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); wordApp.ActiveDocument.ExportAsFixedFormat(outfile, paramExportFormat, paramOpenAfterExport, paramExportOptimizeFor, paramExportRange, paramStartPage, paramEndPage, paramExportItem, paramIncludeDocProps, paramKeepIRM, paramCreateBookmarks, paramDocStructureTags, paramBitmapMissingFonts, paramUseISO19005_1, ref missing); catch (Exception ex) throw ex; finally if (wordApp != null) wordApp.Quit(ref missing, ref missing, ref missing); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); }

PDF转Word完全指南:3大方法满足各种场景! 还不知道PDF怎么转Word吗,本文将提供完整的PDF转Word方案,包括离线、在线或者SDK API等各种方式,总有一款满足您的需求。
geovindu 读者是,读之者,者之读.一沙一世界! to be is to do举世皆清我独浊,众人皆醒我独醉.俺是农民工,程序员.