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

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

问题描述

我有一个我想打开的Xlsx文件,用后端的数据填充,然后将其作为PDF保存在客户端。该过程一次创建约100个文件。



我在网路上搜索,意识到不可能再使用Excel Interop。我必须使用XML SDK吗?



我不能使用任何第三方产品或API。它使用Interop或XML,但只是寻找编码建议。我有Adobe Pro许可证,并已在Office Automation中使用以将Excel文件保存为PDF格式。



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

解决方案

你是什么意思:不可能再使用Excel Interop ?



办公室2013仍然有Interop库,它在.NET 4.5.1
下完美工作只需将Microsoft.Office.Interop.Excel程序集添加到引用中即可。

 使用系统; 
使用Microsoft.Office.Interop.Excel;

命名空间officeInterop
{
类程序
{
static void Main(string [] args)
{
应用程序应用程序= new Application();
工作簿wkb = app.Workbooks.Open(d:\\\xxlsx);
wkb.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF,d:\\x.pdf);
}
}
}


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.

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?

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.

解决方案

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

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天全站免登陆