创建Excel文件并保存为PDF格式。 [英] Create Excel file and save as PDF.

查看:262
本文介绍了创建Excel文件并保存为PDF格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想开了,从后端数据填充它,然后将其保存为客户端的PDF XLSX文件。这一过程将创造约在时间100个文件。

I have an Xlsx file that I want to open, populate it with data from back-end and then save it as PDF on the client. The process would create about a 100 files at a time.

我在网上搜索周围,并意识到这是不可能使用Excel互操作了。我一定要使用XML SDK?

I searched around the web and realize that it is not possible to use Excel Interop any more. Do I have to use XML SDK?

我不能使用任何第三方产品或API。它要么是使用互操作或XML,但只是为了寻找编码建议。我也有Adobe亲执照和办公自动化已经习惯了Excel文件保存为PDF格式。

I cannot use any third-party products or APIs. It is either using Interop or XML but just looking for coding suggestions. I do have Adobe pro license and have used in Office Automation to save Excel files as PDF.

什么是我的选择? 。任何建议,将不胜感激。

What are my options? Any recommendation would be greatly appreciated.

推荐答案

你是什么意思着:这是不可能使用Excel互操作更多的

What do you mean with: "it is not possible to use Excel Interop any more"?

办公室2013年仍然有互操作库和它的作品在.NET 4.5.1
完美的罚款只是组装的Microsoft.Office.Interop.Excel添加到您的引用,你准备好了。

Office 2013 still have Interop library and it works perfectly fine under .NET 4.5.1 Just add Microsoft.Office.Interop.Excel assembly to your references and you are ready to go.

using System;
using Microsoft.Office.Interop.Excel;

namespace officeInterop
{
    class Program
    {
        static void Main(string[] args)
        {
            Application app = new Application();
            Workbook wkb = app.Workbooks.Open("d:\\x.xlsx");
            wkb.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, "d:\\x.pdf");
        }
    }
}

这篇关于创建Excel文件并保存为PDF格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆