ExceL转PDF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
namespace ExcelToPdfDemo
{
class Program
{
static void Main(string[] args)
{
try
{
string path = @"C:\\aa.xls";
string path2 = @"C:\\cc.pdf";
XLSConvertToPDF(path,path2);
Console.WriteLine("转换成功!");
Console.ReadKey();
}
catch (Exception)
{ throw;
} }
///<summary>
/// 把Excel文件转换成PDF格式文件
///</summary>
///<param name="sourcePath">源文件路径</param>
///<param name="targetPath">目标文件路径</param>
///<returns>true=转换成功</returns>
private static bool XLSConvertToPDF(string sourcePath, string targetPath)
{
bool result = false;
Excel.XlFixedFormatType targetType = Excel.XlFixedFormatType.xlTypePDF;
object missing = Type.Missing;
Excel.Application application = null;
Excel.Workbook workBook = null;
try
{
application = new Excel.Application();
object target = targetPath;
object type = targetType;
workBook = application.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, missing);
result = true;
}
catch
{
result = false;
}
finally
{
if (workBook != null)
{
workBook.Close(true, missing, missing);
workBook = null;
}
if (application != null)
{
application.Quit();
application = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
return result;
} }
}
ExceL转PDF的更多相关文章
- java操作word,excel,pdf
在平常应用程序中,对office和pdf文档进行读取数据是比较常见的功能,尤其在很多web应用程序中.所以今天我们就简单来看一下java对word.excel.pdf文件的读取.本篇博客只是讲解简单应 ...
- 导出excel和PDF小结 vba
最近接触了一个关于Access工具的项目,所以整理下需要使用的方法. 功能要求简介: 1.将数据表中的数据导出到excel和PDF 2.并根据某个字段名称分sheet输出. 3.无模板方式 方案简介: ...
- Atitit.office word excel ppt pdf 的web在线预览方案与html转换方案 attilax 总结
Atitit.office word excel ppt pdf 的web在线预览方案与html转换方案 attilax 总结 1. office word excel pdf 的web预览要求 ...
- 自制 Word、Excel 批转 PDF 工具
原文:自制 Word.Excel 批转 PDF 工具 目前做金融业的项目,该公司每天会产生很多 Word.Excel 文档,需要大量地转换为 PDF,除了自己保存外,也要给金融主管机构作为备份.由于文 ...
- C#, VB.NET如何将Excel转换为PDF
在日常工作中,我们经常需要把Excel文档转换为PDF文档.你是否在苦恼如何以C#, VB.NET编程的方式将Excel文档转换为PDF文档呢?你是否查阅了许多资料,运用了大量的代码,但转换后的效果依 ...
- Jacob工具类使用文件互转服务 word转html html转excel word转pdf excel转pdf ppt转pdf
前提条件 必须安装MS office 1.jdk使用jdk1.8 2.jacob.dll放在..\jdk1.8\jre\bin目录下 3.eclipse的jre版本要和jdk一致,window-&g ...
- 操作Work、Excel、PDF
操作Work.Excel.PDF 1.NPOI插件 namespace XBLRDiff.BLL.Excel { public class ExcelImport:IDisposable ...
- python数据处理excel和pdf,并打包成exe
之前零散的用过一点python做数据处理,这次又遇到一个数据处理的小功能,因此,记录一下整个流程,方便以后查阅. 功能要求:读取excel,找指定的PDF文件的页数是否与excel中记录的一致 整个处 ...
- 利用java实现excel转pdf文件
在有些需求当中我们需要抓取字段并且填充到excel表格里面,最后将excel表格转换成pdf格式进行输出,我第一次接触这个需求时,碰到几个比较棘手的问题,现在一一列出并且提供解决方案. 1:excel ...
- Ionic2+WebApi 导出Excel转Pdf文件。
步骤: 1.首先在WebApi中先把excel生成好. 2.把excel转成Pdf,并返回下载的链接. 3.Ionic2的页面做好下载的接口. 嗯~思路很清晰,那么下面就来详细的操作吧. 以下是H5的 ...
随机推荐
- 关于Android L软件安装问题的发现
android5.0可能存在的问题: 保留数据刷入导致通知栏无法下拉 按home键不能回到桌面 sdcard无法读取等等 刷了Android L之后,有一部分软件无法正常安装,多表现为 同一家公司开发 ...
- ggplot2 scale相关设置
ggplot2 scale相关设置 标度设置:主要用于在ggplot画图后的各个图层进行调整设置. 1.相关属性scale设置 包括scale_size().scale_alpha().scal ...
- jquery之全选全不选
<input type="checkbox" onclick="selall(this)" />全选/全不选 <input type=&quo ...
- SourceInsight - 常用设置和快捷键大全
1. 让{ 和 } 不缩进 Options -> Document Options -> Auto Indenting -> Auto Indent Type 选 Simple 2. ...
- 在 iOS 应用中直接跳转到 AppStore 的方法
找到应用程序的描述链接,在itunes中找到相应的应用,(如下图),点击免费右边的下方向键,选择复制链接,就拿到了对应的app的描述链接 比如:https://itunes.apple.com/c ...
- uilabel 复制
//添加一个长按响应方法 - (void)addLongPressGestureRecognizer { UILongPressGestureRecognizer * longPress = [[UI ...
- iOS 加载本地的html文件
方法1: self.webView = [[UIWebView alloc]initWithFrame:self.view.bounds]; NSString *path = [[NSBundle ...
- 比较全的 C# 操作 Word的代码
using System;using System.Collections.Generic;using System.Text;using Microsoft.Office.Interop.Word; ...
- Python基础(四)-集合
补充: 数据类型分类: 1.按照数据可变不可变: 可变:列表.字典 不可变:数字.字符串.元组 x={':1} print(id(x)) x.update({':2}) print(x) print( ...
- hadoop namespace
As underscore(_) is not allowed. It may be the problem if your other configuration are ok. Your conf ...