0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C#とVB.NETでPDF を Excel に変換する

Posted at

はじめに

PDFはデータの保存や転送には非常に便利ですが、データを処理する場合はExcelがより適しています。そのような場合には、PDFをExcel形式に変換することができます。これにより、PDFからデータを抽出したり、編集したり、分析したりすることが非常に便利です。以下に、詳細な手順をご紹介します。

ツール

このライブラリは、無料でPDFファイルを作成、編集、変換することができますが、ページ数の制限があります。または、有料版の製品の無料トライアルを申し込むこともできます。
Spire.PDF for .NET

インストール方法

  1. Free Spire.PDF for .NETをダウンロードします。
  2. Visual Studioで新しいプロジェクトを作成します。
  3. 「Solution Explorer」で「References」を右クリックし、「Add Reference」>「Browse」を選択します。
  4. BINフォルダ内のdllファイルを見つけて、「OK」をクリックします。

コード

C#:

using Spire.Pdf;
using Spire.Pdf.Conversion;
namespace ConvertPdfToExcel
{
    class Program
    {
        static void Main(string[] args)
        {             
            //PdfDocumentクラスのインスタンスを初期化する
            PdfDocument pdf = new PdfDocument(); 

            //PDFドキュメントをロードする
            pdf.LoadFromFile("sample.pdf");              

            //PDFドキュメントをXLSXに保存する
            pdf.SaveToFile("PdfToExcel.xlsx", FileFormat.XLSX);        
        }    
    }
}

VB.NET:

Imports Spire.Pdf
Imports Spire.Pdf.Conversion

Namespace ConvertPdfToExcel
    
    Class Program
        
        Private Shared Sub Main(ByVal args() As String)
            'PdfDocumentクラスのインスタンスを初期化する
            Dim pdf As PdfDocument = New PdfDocument

            'PDFドキュメントをロードする
            pdf.LoadFromFile("sample.pdf")

            'PDFドキュメントをXLSXに保存する
            pdf.SaveToFile("PdfToExcel.xlsx", FileFormat.XLSX)
        End Sub
    End Class
End Namespace

このコードでは、PdfDocument クラスのインスタンスを初期化します。次に、PdfDocument.LoadFromFile() メソッドを使用して 「sample.pdf」をロードします。そして、PdfDocument.SaveToFile() メソッドを使用してPDF を Excel に保存します。
image.png

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?