Convert PDF to Excel using C# in asp.net

Posted by Webmasters964 under ASP.NET on 9/6/2013 | Points: 10 | Views : 21418 | Status : [Member] | Replies : 12
Hi ,

Convert PDF to Excel using C# in asp.net

Any help any idea..




Responses

Posted by: Bandi on: 9/6/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer:
http://www.sautinsoft.net/help/excel-to-pdf-net/html/09b70769-d39c-45e6-7352-90355fe5f3c2.htm

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/6/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear

Spire.XLS for .NET is .NET Excel component which enables your .NET applications to fast generate, read, write and modify Excel document without Microsoft Office Excel Automation.

Download link : http://www.e-iceblue.com/Download/download-excel-for-net-now.html

Convert excel to Pdf.

[C#]

using Spire.Xls;

using Spire.Pdf;
using Spire.Xls.Converter;

namespace ExceltoPDF
{
class Program
{
static void Main(string[] args)
{
// load Excel file
Workbook workbook = new Workbook();
workbook.LoadFromFile("D:\\test.xlsx");

// Set PDF template
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
pdfDocument.PageSettings.Width = 970;
pdfDocument.PageSettings.Height = 850;

//Convert Excel to PDF using the template above
PdfConverter pdfConverter = new PdfConverter(workbook);
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
pdfDocument = pdfConverter.Convert(settings);

// Save and preview PDF
pdfDocument.SaveToFile("sample.pdf");
System.Diagnostics.Process.Start("sample.pdf");
}
}
}


Link :
http://www.e-iceblue.com/Knowledgebase/Spire.XLS/Program-Guide/Convert-Excel-to-PDF-with-Spire.XLS.html
http://neevia.com/support/examples/cr/?get=ex003cnet


PDF to Excel using C# in asp.net

Code :


////////////////////////////////////////////////////////////////////////////////////////////////////

// This example was designed for using in Microsoft Visual C# from
// Microsoft Visual Studio 2003 or above.
//
// 1. Microsoft Excel 97 or above should be installed and activated on your PC.
//
// 2. Before using this example, please read this article from Microsoft Excel 2003 knowledge base:
// http://support.microsoft.com/kb/320369/en-us/
// A workaround for this issue is available in this example.
//
// 3. Universal Document Converter 5.2 or above should be installed, too.
//
// 4. Add references to "Microsoft Excel XX.0 Object Library" and "Universal Document Converter Type Library"
// using the Project | Add Reference menu > COM tab.
// XX is the Microsoft Office version installed on your computer.
////////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.IO;
using UDC;
using Excel = Microsoft.Office.Interop.Excel; //using Excel; in VS2003

namespace ExcelToPDF
{
class Program
{
static void PrintExcelToPDF(string ExcelFilePath)
{
//Create a UDC object and get its interfaces
IUDC objUDC = new APIWrapper();
IUDCPrinter Printer = objUDC.get_Printers("Universal Document Converter");
IProfile Profile = Printer.Profile;

//Use Universal Document Converter API to change settings of converterd document
Profile.PageSetup.ResolutionX = 600;
Profile.PageSetup.ResolutionY = 600;

Profile.FileFormat.ActualFormat = FormatID.FMT_PDF;

Profile.FileFormat.PDF.ColorSpace = ColorSpaceID.CS_TRUECOLOR;
Profile.FileFormat.PDF.Multipage = MultipageModeID.MM_MULTI;

Profile.OutputLocation.Mode = LocationModeID.LM_PREDEFINED;
Profile.OutputLocation.FolderPath = @"c:\UDC Output Files";
Profile.OutputLocation.FileName = @"&[DocName(0)] -- &[Date(0)] -- &[Time(0)].&[ImageType]";
Profile.OutputLocation.OverwriteExistingFile = false;

Profile.PostProcessing.Mode = PostProcessingModeID.PP_OPEN_FOLDER;

//Create a Excel's Application object
Excel.Application ExcelApp = new Excel.ApplicationClass();

Object ReadOnly = true;
Object Missing = Type.Missing; //This will be passed when ever we don’t want to pass value

//If you run an English version of Excel on a computer with the regional settings are configured for a non-English language, you must set the CultureInfo prior calling Excel methods.
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
//Open the document from a file
Excel.Workbook Workbook = ExcelApp.Workbooks.Open(ExcelFilePath, Missing, ReadOnly, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);

//Change active worksheet settings and print it
Excel.Worksheet Worksheet = (Excel.Worksheet)Workbook.ActiveSheet;
Excel.PageSetup PageSetup = Worksheet.PageSetup;

PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;

Object Preview = false;
Worksheet.PrintOut(Missing, Missing, Missing, Preview, "Universal Document Converter", Missing, Missing, Missing);

//Close the spreadsheet without saving changes
Object SaveChanges = false;
Workbook.Close(SaveChanges, Missing, Missing);

//Close Microsoft Excel
ExcelApp.Quit();
}

static void Main(string[] args)
{
string TestFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.xls");
PrintExcelToPDF(TestFilePath);
}
}
}


Link :
http://bytescout.com/products/developer/pdfextractorsdk/convert-pdf-to-excel-csv
http://social.msdn.microsoft.com/Forums/vstudio/en-US/a56b093b-2854-4925-99d5-2d35078c7cd3/converting-pdf-file-into-excel-file-using-c
http://www.moretechtips.net/2013/01/how-to-convert-pdf-to-excel-in-net.html

Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER


Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Webmasters964 on: 9/6/2013 [Member] Starter | Points: 25

Up
0
Down
How to Convert PDF Files to Excel Files using C# in asp.net

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/6/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Have you tried my code?

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/6/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
There is no native methods to convert PDF to Excel files in ASP .NET C#..
We should use any one of third party tools for the conversion... That is the reason Mahesh & am provided those codes... Both codes are third party dependents

Refer this link
http://forums.asp.net/t/1227922.aspx
For Excel to PDF conversion Try this
If there is fixed format of data and fixed number of columns in the excel sheet follows these steps
1) Import Excel data to databse and then into Dataset(gridView)
2) Save GridView data to PDF file

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: t5j9033387989 on: 11/28/2013 [Member] Starter | Points: 25

Up
0
Down
Hey try with this code,

using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Advanced;
namespace WorkOnPdfObjects
{
class Program
{
static void Main()
{
const string filename = "StudentFormat.pdf";
File.Copy(Path.Combine("../../../../../PDFs/", filename),
Path.Combine(Directory.GetCurrentDirectory(), filename), true);
PdfDocument document = PdfReader.Open(filename);
PdfDictionary dict = new PdfDictionary(document);
dict.Elements["/S"] = new PdfName("/GoTo");
PdfArray array = new PdfArray(document);
dict.Elements["/D"] = array;
PdfReference iref = PdfInternals.GetReference(document.Pages[2]);
array.Elements.Add(iref);
array.Elements.Add(new PdfName("/FitV"));
array.Elements.Add(new PdfInteger(-32768));
document.Internals.AddObject(dict);
document.Internals.Catalog.Elements["/OpenAction"] =
PdfInternals.GetReference(dict);
document.Save(filename);
Process.Start(filename);
}
}
}


mark this answer if it will really help you,

Thanks&Regards
ketan

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 11/28/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Try with the following code:

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.PDFExtractor;
using System.Diagnostics;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Create Bytescout.PDFExtractor.CSVExtractor instance
CSVExtractor extractor = new CSVExtractor();
extractor.RegistrationName = "demo";
extractor.RegistrationKey = "demo";

// Load sample PDF document
extractor.LoadDocumentFromFile("sample3.pdf");

//extractor.CSVSeparatorSymbol = ","; // you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales

extractor.SaveCSVToFile("output.csv");

Console.WriteLine();
Console.WriteLine("Data has been extracted to 'output.csv' file.");
Console.WriteLine();
Console.WriteLine("Press any key to continue and open CSV in default CSV viewer (or Excel)...");
Console.ReadKey();

Process.Start("output.csv");
}
}
}


Mark as answer if satisfied...

Regards,
Shree M.

Kavya Shree Mandapalli

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samirbhogayta on: 12/4/2013 [Member] Starter | Points: 25

Up
0
Down
this link helps you

http://www.codeproject.com/Questions/651582/how-to-convert-pdf-file-to-excel-file-using-csharp

SAMIR
Sr. Software Engineer

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thackeray on: 4/2/2014 [Member] Starter | Points: 25

Up
0
Down
I am using visual basic to programming excel to pdf conversion on the contrary, as I can search and find the available pdf to excel converter.

http://www.rasteredge.com/how-to/vb-net-imaging/excel-convert-pdf/


Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Zaiba on: 4/3/2014 [Member] Starter | Points: 25

Up
0
Down
Check out this link for sample code to convert pdf file to excel using C#/VB.NET. I hope it will help you solve your problem.

http://www.aspose.com/docs/display/pdfnet/Convert+PDF+to+Excel+workbook

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mattyclown on: 6/5/2014 [Member] Starter | Points: 25

Up
0
Down
actually you can convert PDF to bitmap image and then create excel with that bitmap image source.

http://www.rasteredge.com/how-to/vb-net-imaging/pdf-render-option/


Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Evanpan on: 9/26/2015 [Member] Starter | Points: 25

Up
0
Down
I wonder how do deal with those code? Do I need another pdf converter like this?
http://www.pqscan.com/convert-pdf/

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response