版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、最新资料推荐using systemusing System; using System.Collections.Generic; usingSystem.ComponentModel; using System.Data; usingSystem.Drawing; using System.Linq; using System.Text; usingusing Word = using Excel=usingPowerPoint=namespace test class Form3 : Form public Form3() InitializeComponent();System.Wind
2、ows.Forms; using System.Threading; using System.IO;using Microsoft.Office.Core;Microsoft.Office.Interop.Word;Microsoft.Office.Interop.Excel;Microsoft.Office.Interop.PowerPoint; public partialSystem.Windows.Forms.Control.CheckForIllegalCrossThreadCall/ToolTipfalse;this.CheckForIllegalCrossThreadCalls
3、 string file_extend = string.Empty;tool_showinfo = new ToolTip();CopyFile copyfile;private void Form3_Load(object sender, EventArgs e)copyfile = new CopyFile(listBox1,private voidEventArgs e)sender,listView1); button1_Click(object1 / 10Thread t = new Thread(copyfile.copy);t.Start(); Thread.Sleep(500
4、0); private void button2_Click(object sender, EventArgs e) private void button3_Click(objectsender, EventArgs e) public class CopyFile public CopyFile(ListBoxlistBox1,ListViewlistView1)this.listBox1= listBox1;this.listView1 = listView1; string dir =C:a;string d = d:a;private ListBoxlistBox1;private
5、ListViewlistView1;/Word 转 a 换 ?成 pdf/ summary /把?Word 文?件 t 转 a 换?成为 aPDF格?式?文?件 t/summary / param name=sourcePath 源 文 ? 件 t 路 径?/param/ param name=targetPath目?标文 ?件 t 路径 ?/param/ returnstrue= 转 a 换 ? 成功 |/returnsprivate bool DOCConvertToPDF(string sourcePath, string targetPath) bool result = false;
6、Microsoft.Office.Interop.Word.WdExportFormat exportFormat = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormat PDF; object paramMissing = Type.Missing;Word.ApplicationClasswordApplicationnew最新资料推荐Microsoft.Office.Interop.Word.ApplicationClass();Microsoft.Office.Interop.Word.Document wordDoc
7、ument = null;try object paramSourceDocPath= sourcePath;string paramExportFilePath =targetPath;Microsoft.Office.Interop.Word.WdExportFormat paramExportFormat = exportFormat; bool paramOpenAfterExport = false;Word.WdExportOptimizeForparamExportOptimizeFor=Word.WdExportOptimizeFor.wdExportOptimizeForPr
8、int;Word.WdExportRangeparamExportRange=Word.WdExportRange.wdExportAllDocument; int paramStartPage = 0;int paramEndPage = 0;Word.WdExportItem paramExportItem = Word.WdExportItem.wdExportDocumentContent;bool paramIncludeDocProps = true; bool paramKeepIRM = true; Word.WdExportCreateBookmarks paramCreat
9、eBookmarks = Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks; bool paramDocStructureTags = true;boolparamBitmapMissingFonts = true; bool3 / 10wordDocument =paramUseISO19005_1 = false;wordApplication.Documents.Open( refparamSourceDocPath,refparamMissing,refparamMissing,refparamMissing,refpar
10、amMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing);if(wordDocument != null)wordDocument.ExportAsFixedFormat(paramExportFilePath, paramExportFormat, paramOpenAfterEx
11、port, paramExportOptimizeFor, paramExportRange, paramStartPage, paramEndPage, paramExportItem, paramIncludeDocProps, paramKeepIRM, paramCreateBookmarks, paramDocStructureTags, paramBitmapMissingFonts, paramUseISO19005_1, ref paramMissing); result = true;/ textBox1.Text += DateTime.Now.ToString() + t
12、 + sourcePath+ 转 a 换 ? 成 功 | + rn; this.listView1.Items.Add(成 功 |);catch /textBox1.Text +=false;DateTime.Now.ToString() + t + sourcePath + 转 a 换?失败 + rn; this.listView1.Items.Add( 失败 ); result =finally最新资料推荐if (wordDocument != null)wordDocument.Close(ref paramMissing,refparamMissing,refparamMissing)
13、;wordDocument = null;if(wordApplication!=null)wordApplication.Quit(ref paramMissing,refparamMissing,refparamMissing);wordApplicationnull;GC.Collect();GC.WaitForPendingFinalizers();GC.Collect();GC.WaitForPendingFinalizers();return result; / summary /把?Excel 文?件 t 转 a 换?成 PDF 格?式?文?件 t/summary/ param
14、name=sourcePath 源 文 ? 件径?/param/ param name=targetPath目?标文?件径 ?/param/ returnstrue= 转a 换 ? 成功 |/returnsprivate bool XLSConvertToPDF(stringsourcePath, stringtargetPath) bool result = false;targetTypeMicrosoft.Office.Interop.Excel.XlFixedFormatTypeMicrosoft.Office.Interop.Excel.XlFixedFormatType.xlTyp
15、ePDF;5 / 10objectmissingType.Missing;Microsoft.Office.Interop.Excel.ApplicationClass application= null; Microsoft.Office.Interop.Excel.Workbook workBook = null; try application = new Microsoft.Office.Interop.Excel.ApplicationClass();object type =workBook =object target = targetPath; targetType;appli
16、cation.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);workBook.ExportAsFixedFormat(targetType, target, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, missing, missing, missing, missi
17、ng); result = true; / textBox1.Text +=DateTime.Now.ToString()+ t + sourcePath + 转 a 换?成功 | + rn;this.listView1.Items.Add( 成 功 |);catch / textBox1.Text +=false;DateTime.Now.ToString() + t + sourcePath + 转 a 换?失败 + rn; this.listView1.Items.Add(失败 );result =finally最新资料推荐if(workBook != null)workBook.Clo
18、se(true,missing, missing);workBook =null; if(application!=null)application.Quit();application = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();GC.WaitForPendingFinalizers(); return result; / summary / 把?PowerPoing 文?件 t 转 a 换?成 PDF格?式 ?文?件 t/summary / param name=sourcePath 源 文 ? 件 t
19、 路 径?/param/ param name=targetPath目?标文 ?件 t 路径 ?/param/ returnstrue= 转 a 换 ? 成功 |/returnsprivate bool PPTConvertToPDF(string sourcePath, string targetPath) bool result; Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType targetFileType = Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSave A
20、sPDF; object missing = Type.Missing; Microsoft.Office.Interop.PowerPoint.ApplicationClass7 / 10application = null;Microsoft.Office.Interop.PowerPoint.Presentationpersentation = null; try application = newMicrosoft.Office.Interop.PowerPoint.ApplicationClass();persentation = application.Presentations.
21、Open(sourcePath,MsoTriState.msoTrue,MsoTriState.msoFalse,MsoTriState.msoFalse);persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);result = true; / textBox1.Text += DateTime.Now.ToString() + t + sourcePath + 转 a 换?成功 | + rn; this.listView1.Items.Add( 成 功 |); catch / textBox1.Text += DateTime.Now.ToString() + t + sourcePath + 转 a 换?失败 + rn;this.listView1.Items.Add(失败 );res
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 浅议香港上市公司之私有化-2024.08-28正式版-WN8
- 湖北省襄阳市枣阳市2024-2025学年数学六年级第一学期期末达标检测模拟试题含解析
- 湖南省常德市澧县2024年六年级数学第一学期期末监测模拟试题含解析
- (资料)年产20万台真空管太阳能热水器生产线项目申请报告
- 年产3000吨高性能PVB中间膜项目可行性研究报告写作模板-备案审批
- 初中物理公式及知识点
- 建设葡萄糖生产线提纯净化工序智能化技改项目可行性研究报告写作模板-备案审批
- 湖南省永州市2025届数学三上期末质量跟踪监视试题含解析
- 湖南省岳阳市平江县2024年数学六上期末学业质量监测试题含解析
- 湖南省株洲市醴陵市2025届数学六上期末检测试题含解析
- 2024年学宪法、讲宪法题库及答案
- 大队委竞选课件
- 课件系解教授小脑
- Pocket英语语法(崔荣容)-视频笔记
- 广州有限公司章程(下载模版
- 42脱硫吸收塔防腐工程施工方案
- 教案 普通植物病理学
- [新版]小学二年级2-5乘法口算练习1000道.docx
- 风力发电故障分析ppt课件
- 土地整治项目验收规程表格
- 农村小学预防地方性氟中毒教学教案(一至六年级)
评论
0/150
提交评论