ITextSharp-Excel(.xls)为PDF(.pdf) [英] ITextSharp - Excel (.xls) to PDF (.pdf)

查看:573
本文介绍了ITextSharp-Excel(.xls)为PDF(.pdf)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在过去的几个小时里一直在网上搜索,寻找一种将.xls格式的excel文档转换的方法(我也有代码,excel应用程序,工作簿和工作表),如果可以使用的话,我正在寻找将其转换为PDF.

在阅读了许多不同的论坛之后,很多人说使用ITextSharp可以做到这一点.我曾经尝试实现这是没有运气的代码,而我还是试图寻找一个给我一些提示却找不到任何提示的教程.

很多人说它是可行的,但是没有人暗示它是如何完成的,如果有人可以帮助解决这个问题,或者可以向我指出正确的方向,我将非常感激

亲切的问候.

尼克

Hi Guys,

Ive been searching the web now for the past few hours looking for a way to convert my excel document in .xls format, (i also have in code, the excel app, workbook and worksheet) if these can be used, and i am looking to convert this into a PDF.

After reading a number of different forums alot of people say this is possible using ITextSharp. I have tried to implement this is code with no luck what so ever, and ive tried looking for a tutorial to give me some hint and cant find any of them.

Alot of people sayu its posible but no one hints at how its done, if anyone could help with this matter or could point me in the right direction i would be very greatful

Kind regards.

Nick

推荐答案

我想这些文章应该会对您有所帮助.你看过他们吗?
使用C#2.0创建PDF文件的教程 [使用C#(.NET 2.0)和iTextSharp创建PDF表 [
I guess these articles should help you out. Did you had a look at them?
Tutorials on creating PDF files using C# 2.0[^]
Creating PDF Tables using C# (.NET 2.0) and iTextSharp[^]


我转换了Excel(.xls)转换为PDF(.pdf).但是我使用了GemBox.Spreadsheet.dll& wnvhtmlconvert.dll.可能会对您有帮助.

I converted Excel (.xls) to PDF (.pdf). But i used GemBox.Spreadsheet.dll & wnvhtmlconvert.dll. It may help you.

using GemBox.Spreadsheet;
using Winnovative.WnvHtmlConvert;

public class PDFBuilder
    {
        private ExcelFile ef = null;
        private string _saveHtmlLocation = "C:\\2.html";
        private string _savePDFLocation = "C:\\1.pdf";

        public PDFBuilder(string FilePath)
        {
            ef = new ExcelFile();
            ef.LoadXls(FilePath);
            ef.SaveHtml(_saveHtmlLocation, null, true);
            PdfConverter pdfConverter = new PdfConverter();
            pdfConverter.LicenseKey = "<insert your="" own="" license="" key="" here="">";
            pdfConverter.PdfDocumentOptions.EmbedFonts = false;
            pdfConverter.PdfDocumentOptions.ShowFooter = false;
            pdfConverter.PdfDocumentOptions.ShowHeader = false;
            pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
            pdfConverter.SavePdfFromHtmlFileToFile(_saveHtmlLocation, _savePDFLocation);
        }
    }</insert>


这篇关于ITextSharp-Excel(.xls)为PDF(.pdf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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