How to convert PDF to Excel and PDF to Word in C#/VB.NET

Poster
Posted by in .NET Framework category on for Intermediate level | Points: 250 | Views : 389 red flag

PDF is widely used for its convenience and safety on the Internet. Word and Excel files are more common in their degree of versatility and editability. Converting a batch of PDF documents to Excel or Word manually is a very time-consuming task, in this article, I will show you how to convert PDF to Excel and PDF to Word programmatically in C# and VB.NET by using Spire.PDF for .NET API.


Spire.PDF for .NET is a standalone API that supports creating, manipulating, printing and converting PDF files. You can either installing the API via NuGet or downloading the dll of the API from this website.

In the following screenshots you can see the input PDF file and the output excel/word file.u can see the input PDF file and the output excel/word file.


Output Excel worksheet:


Output Word Document:


Spire.PDF offers pdf.SaveToFile() method to enables developers to save PDF to other formats easily. Check the code snippets as below:

C# code

using Spire.Pdf;

namespace ConvertPDFtoExcel
{
    class Program
    {
        static void Main(string[] args)

        {
            //Create a PdfDocument instance
            PdfDocument pdf = new PdfDocument();
            //Load the PDF file
            pdf.LoadFromFile("Sample.pdf");
            //Save to Excel
            pdf.SaveToFile("PDFToExcel.xlsx", FileFormat.XLSX);
            //Save to Word
            //pdf.SaveToFile("PDFtoWord.Docx", FileFormat.DOCX);

        }
    }
    
}

VB.NET Code

Imports Spire.Pdf

Namespace ConvertPDFtoExcel
    
    Class Program
        
        Private Shared Sub Main(ByVal args() As String)
            'Create a PdfDocument instance
            Dim pdf As PdfDocument = New PdfDocument
            'Load the PDF file
            pdf.LoadFromFile("Sample.pdf")
            'Save to Excel
            pdf.SaveToFile("PDFToExcel.xlsx", FileFormat.XLSX)
            'Save to Word
            'pdf.SaveToFile("PDFtoWord.Docx", FileFormat.DOCX);
        End Sub
    End Class
End Namespace
I hope you learned how to convert PDF to editable files formats in Excel and Word using Spire.PDF from my article. There are many other useful features to operate PDF from code that I haven't mentioned, such as add digital signature to PDF, merge and split PDF files. However, I am ending the article here to keep it within limits. You can give them a try by yourself if you're interested. Happy learning!



Page copy protected against web site content infringement by Copyscape

About the Author

Poster
Full Name: Ms poster
Member Level:
Member Status: Member
Member Since: 8/29/2007 10:18:25 AM
Country:


-- Hobby for DotNet

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)