Excel转换成PDF
- public class Office2Pdf
- {
- public bool DOCConvertToPDF(string sourcePath, string targetPath)
- {
- //StreamReader reader = new StreamReader("temp.doc", Encoding.GetEncoding("gb2312"));
- //string text = reader.ReadToEnd();
- //Aspose.Words.Document doc = new Aspose.Words.Document();
- //Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
- //builder.Write(text);
- //doc.Save("temp.pdf", SaveFormat.Pdf);
- //reader.Close();
- bool result = false;
- Word.WdExportFormat exportFormat = Word.WdExportFormat.wdExportFormatPDF;
- object paramMissing = Type.Missing;
- Word.ApplicationClass wordApplication = new Word.ApplicationClass();
- Word.Document wordDocument = null;
- try
- {
- object paramSourceDocPath = sourcePath;
- string paramExportFilePath = targetPath;
- Word.WdExportFormat paramExportFormat = exportFormat;
- bool paramOpenAfterExport = false;
- Word.WdExportOptimizeFor paramExportOptimizeFor = Word.WdExportOptimizeFor.wdExportOptimizeForPrint;
- Word.WdExportRange paramExportRange = Word.WdExportRange.wdExportAllDocument;
- int paramStartPage = ;
- int paramEndPage = ;
- 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;
- wordDocument = wordApplication.Documents.Open(
- ref paramSourceDocPath, ref paramMissing, ref paramMissing,
- ref paramMissing, ref paramMissing, ref paramMissing,
- ref paramMissing, ref paramMissing, ref paramMissing,
- ref paramMissing, ref paramMissing, ref paramMissing,
- ref paramMissing, ref paramMissing, ref paramMissing,
- ref paramMissing
- );
- if (wordDocument != null)
- wordDocument.ExportAsFixedFormat(
- paramExportFilePath, paramExportFormat, paramOpenAfterExport,
- paramExportOptimizeFor, paramExportRange, paramStartPage,
- paramEndPage, paramExportItem, paramIncludeDocProps,
- paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
- paramBitmapMissingFonts, paramUseISO19005_1, ref paramMissing
- );
- return true;
- }
- catch (Exception ex)
- {
- ex.WriteLog(ex.ToString());
- return false;
- }
- finally
- {
- if (wordDocument != null)
- {
- wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing);
- wordDocument = null;
- }
- if (wordApplication != null)
- {
- wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing);
- wordApplication = null;
- }
- GC.Collect();
- GC.WaitForPendingFinalizers();
- GC.Collect();
- GC.WaitForPendingFinalizers();
- }
- return result;
- }
- }
Excel转换成PDF的更多相关文章
- 多页Excel转换成PDF时如何保存为单独文件
通过ABBYY PDF Transformer+图文识别软件,使用PDF-XChange打印机将多页Excel工作簿转换成PDF文档(相关文章请参考ABBYY PDF Transformer+从MS ...
- excel 转换成pdf 总结
excl 转换成pdf 1.freespire 只能转换前三页 // 使用此组件 只能转换前3页 //需要引用 如下命名空间 //using Spire.Doc; //Document doc = ...
- python实现excel转换成pdf
1.安装 需要安装pywin32包,以实现对Office文件的操作,可以批量转换为pdf文件.支持 doc, docx, ppt, pptx, xls, xlsx 等格式. pip install p ...
- word ppt excel文档转换成pdf
1.把word文档转换成pdf (1).添加引用 using Microsoft.Office.Interop.Word; 添加引用 (2).转换方法 /// <summary> /// ...
- C#.net word excel powerpoint (ppt) 转换成 pdf 文件
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- C#实现文档转换成PDF
网上有很多将doc.ppt.xls等类型的文档转换成pdf的方法,目前了解到的有两大类: 1.使用虚拟打印机将doc.ppt.xls等类型的文档 2.使用OFFICE COM组件 我采用了第二种方法实 ...
- c# office转换成pdf
下载地址 [url]http://www.microsoft.com/downloads/details.aspx?FamilyId=4D951911-3E7E-4AE6-B059-A2E79ED87 ...
- C#将Word转换成PDF方法总结(基于Office和WPS两种方案)
有时候,我们需要在线上预览word文档,当然我们可以用NPOI抽出Word中的文字和表格,然后显示到网页上面,但是这样会丢失掉Word中原有的格式和图片.一个比较好的办法就是将word转换成pdf,然 ...
- ASP.Net中实现上传过程中将文本文件转换成PDF的方法
iTextSharp是一个常用的PDF库,我们可以使用它来创建.修改PDF文件或对PDF文件进行一些其他额外的操作.本文讲述了如何在上传过程中将文本文件转换成PDF的方法. 基本工作 在开始之前,我们 ...
随机推荐
- CSS:7个你可能不认识的单位
原文:7 CSS Units You Might Not Know About 众所周知,当使用CSS技术的时候,很容被一些奇异问题给困住.而当我们面对新的问题时,这会让我们处于非常不利的位置. 但是 ...
- 线段相交 poj 1066
// 线段相交 poj 1066 // 思路:直接枚举每个端点和终点连成线段,判断和剩下的线段相交个数 // #include <bits/stdc++.h> #include <i ...
- A题进行时--浙大PAT 1011-1020
#include<stdio.h> #include<string.h> int main(){ ]; ]; ]; ]; ]; int i; float sum; memset ...
- java 中 正则 正则表达式 匹配 url
不多说 [http|https]+[://]+[0-9A-Za-z:/[-]_#[?][=][.][&]]* 这个就是匹配 网络上的网址 又称 url . 最起码 绝大部分的taobao ur ...
- openstack 整合
- ColorNote.疑难解答
首先感谢你对colornote的支持 在使用此应用的过程中,存在任何问题,请先在此页面查看是否有对应的解决方案[Ctrl + F 搜索] 如果问题无法解决,请在页面下方留言,或者邮件light.z@q ...
- iOS 使用FMDB SQLCipher给数据库加密
关于SQLite,SQLCipher和FMDB SQLite是一个轻量的.跨平台的.开源的数据库引擎,它的在读写效率.消耗总量.延迟时间和整体简单性上具有的优越性,使其成为移动平台数据库的最佳解决方案 ...
- inline(内联函数)
一般来说,调用函数会造成:目前的指令位置被存储下来,程序流跳转到所调用的函数,然后执行调用函数,最后跳转回之前存储的位置.对于需要常常调用的小函数来说,这会影响程序的运行效率.所以,c99新增了inl ...
- eclipse中如何设置tomcat启动时间
现象:在eclipse中启动tomcat总是提示“Server Tomcat v5.5 Server @ localhost was unable to start within 45 seconds ...
- CentOS 下安装操作Memcached
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度.Memcached ...