How to Convert PDF File in to Excel using Code in asp.net C#
i want to Convert PDF File in to Excel using Code in asp.net C#.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Saber ShaikhRank #1,686 · 905 reputationPosted Dec 22, 2014, 3:19 AM EST
Check This Link
https://social.msdn.microsoft.com/Forums/vstudio/en-US/a56b093b-2854-4925-99d5-2d35078c7cd3/converting-pdf-file-into-excel-file-using-c
It is Use For to Your Work
Thank You
My Blog: http://aspnettutorialscode.blogspot.in/
Marvin ReidRank #1,963 · 746 reputationPosted Mar 30, 2023, 1:27 PM EDT
You can use the DocumentConverter class to convert the PDF file to an Excel file. Here is an example:
using (DocumentConverter documentConverter = new DocumentConverter()) { var input = @"C:\Input\input.pdf"); var output = @"C:\Output\output.xls"); var jobData = DocumentConverterJobs.CreateJobData(input, output, DocumentFormat.Xls); jobData.JobName = "Convert to Excel"; var documentWriter = new DocumentWriter(); documentConverter.SetDocumentWriterInstance(documentWriter); var renderingEngine = new AnnWinFormsRenderingEngine(); documentConverter.SetAnnRenderingEngineInstance(renderingEngine); var job = documentConverter.Jobs.CreateJob(jobData); documentConverter.Jobs.RunJob(job); }https://www.leadtools.com/help/sdk/tutorials/dotnet-convert-files-with-the-document-converter.html
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 30, 2023, 2:19 PM EDT
There are several libraries available that can be used to convert a PDF file into an Excel file in ASP.NET C#. One popular library is the iTextSharp library.
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 30, 2023, 2:21 PM EDT
To convert a PDF file into an Excel file using ItextSharp
using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.Data; using System.IO; public void ConvertPDFToExcel(string pdfFilePath, string excelFilePath) { // Read the PDF file PdfReader pdfReader = new PdfReader(pdfFilePath); // Create a new Excel file FileStream fileStream = new FileStream(excelFilePath, FileMode.Create); StreamWriter streamWriter = new StreamWriter(fileStream); DataTable dataTable = new DataTable(); // Loop through each page in the PDF file for (int page = 1; page <= pdfReader.NumberOfPages; page++) { // Get the text from the current page ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentPageText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); // Split the text into lines string[] lines = currentPageText.Split('\n'); // Loop through each line and add it to the DataTable foreach (string line in lines) { string[] cells = line.Split('\t'); DataRow dataRow = dataTable.NewRow(); for (int i = 0; i < cells.Length; i++) { dataRow[i] = cells[i]; } dataTable.Rows.Add(dataRow); } } // Write the DataTable to the Excel file for (int i = 0; i < dataTable.Columns.Count; i++) { streamWriter.Write(dataTable.Columns[i].ColumnName + "\t"); } streamWriter.Write("\n"); for (int i = 0; i < (dataTable.Rows.Count); i++) { for (int j = 0; j < dataTable.Columns.Count; j++) { streamWriter.Write(Convert.ToString(dataTable.Rows[i][j]) + "\t"); } streamWriter.Write("\n"); } // Clean up streamWriter.Close(); fileStream.Close(); pdfReader.Close(); }Leon DRank #851 · 2.6K reputationPosted Apr 3, 2023, 9:26 PM EDT
Hi Sompal,
You can convert PDF files to Excel format using Spire.PDF for .NET.
using Spire.Pdf; using Spire.Pdf.Conversion; namespace ConvertPdfToExcel { class Program { static void Main(string[] args) { //Initialize an instance of PdfDocument class PdfDocument pdf = new PdfDocument(); //Load the PDF document pdf.LoadFromFile("Sample.pdf"); //Save the PDF document to XLSX pdf.SaveToFile("PdfToExcel.xlsx", FileFormat.XLSX); } } }You can also check this link for more detailed information:
https://www.e-iceblue.com/Tutorials/Spire.PDF/Program-Guide/Conversion/Convert-PDF-to-Excel-in-C-VB.NET.html
Vishal YelveRank #178 · 13.6K reputationPosted Apr 4, 2023, 8:23 AM EDT
Hi Sompal,
Please refer below links
https://www.codeproject.com/Questions/651582/how-to-convert-pdf-file-to-excel-file-using-csharp
https://blog.groupdocs.com/conversion/convert-document-to-excel-xls-xlsx-in-csharp/
https://social.msdn.microsoft.com/Forums/windows/en-US/590626ba-8884-4192-9041-1cbe5e6318a1/export-pdf-as-excel-using-c
https://sautinsoft.com/products/pdf-focus/help/net/developer-guide/asp-net-export-pdf-to-excel-csharp-vb-net.php