Click here to Skip to main content
11,496,146 members (336 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: C# Excel PDF
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 7-Oct-10 7:03am
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[^]
  Permalink  
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>
  Permalink  
v3
Comments
Kythen at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 29 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100