Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
Posted

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[^]
 
Share this answer
 
I converted Excel (.xls) to PDF (.pdf). But i used GemBox.Spreadsheet.dll & wnvhtmlconvert.dll. It may help you.

C#
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>
 
Share this answer
 
v3
Comments
Kythen 7-Oct-10 14:31pm    
I'm pretty sure the developer(s) of that PDF converter library would appreciate it if you did not share your license key with everyone.
shakil0304003 9-Oct-10 3:37am    
That was free license key & i did not do it intentionally. Sorry for my mistake.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900