製品比較 IronWordとMicrosoft.Office.Interop.Wordの比較 Jordi Bardia 更新日:8月 4, 2025 Download IronWord NuGet Download Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 1. はじめに 多くの開発者は、Word ドキュメントを処理する必要がある .NET アプリケーションで作業しています。 これは、レポートの作成、ドキュメントの処理、または請求書の生成のためかもしれません。 このために人気のある2つのツールが、Microsoft.Office.Interop.Word と IronWord です。 それぞれ独自の機能、利点、および欠点があります。 This article will compare Microsoft.Office.Interop.Word and IronWord. 各ツールが提供するものや、それらのパフォーマンス、どのようなシナリオで最適に使用できるかを見ていきます。 これにより、特定のニーズに最適なツールを決定するのに役立ちます。 2. Microsoft.Office.Interop.Word Microsoft.Office.Interop.Word は .NET アプリケーションが Microsoft Word ドキュメントと直接やり取りできるようにするライブラリです。 Word ドキュメントプロセスを自動化したり、.NET アプリケーションに Word ドキュメント操作機能を統合したりする必要がある開発者にとって重要なコンポーネントです。 このライブラリは、ドキュメントの生成、修正、および .NET 環境内での書式設定などのタスクに特に便利です。Microsoft Word の完全な機能を活用します。 2.1 キーフィーチャー ドキュメントの作成と編集: Microsoft.Office.Interop.Word は、Word ドキュメントの作成と編集のための広範なサポートを提供します。 開発者は、プログラムを使用してテキストを追加、修正、削除したり、タイトルや件名などのドキュメントプロパティを管理したりできます。 この機能は、ユーザー入力または外部データソースに基づいて動的ドキュメントを生成するために不可欠です。 書式設定とスタイル: このライブラリは、テキスト、段落、ドキュメント全体の書式設定に対する包括的なオプションを提供します。 開発者は、さまざまなスタイル、フォント、カラー、および段落の配置を適用して、プロフェッショナルなフォーマットのドキュメントを作成できます。 これには、デフォルトスタイルを超えてカスタムスタイルを定義して適用する機能が含まれており、生成されたドキュメントが特定のブランディングまたはデザイン要件を満たすようにします。 Microsoft Word との互換性: Microsoft Office スイートの一部として、Microsoft.Office.Interop.Word は Microsoft Word のすべての機能と高い忠実度と互換性を保証します。 これには、Word の最新バージョンとのシームレスな統合が含まれており、ライブラリを通じて作成または変更されたドキュメントが Word のネイティブフォーマットと完全に互換性があることが保証されます。 3. IronWord IronWord は、ドキュメント操作のために設計された .NET ライブラリであり、特に Word ドキュメントの処理を対象としています。 Microsoft.Office.Interop.Word が Microsoft Office スイートに依存しているのに対し、IronWord は .NET アプリケーション内で Word ドキュメントを作成、編集、変換するためのスタンドアロンソリューションを提供します。 このため、サーバーやクライアントマシンに Microsoft Word をインストールする必要がないライブラリを探している開発者にとって、魅力的な選択肢となります。 3.1 主な機能 スタンドアロンのドキュメント処理: IronWord は .NET アプリケーション内で Microsoft Office Word をインストールすることなく、Word ドキュメントを操作することを可能にします。 この独立性により、特にサーバーまたはクラウド環境では、開発環境の展開を容易にし、複雑さを軽減します。 ドキュメント変換: IronWord の大きな機能は、Word ドキュメントを PDF、HTML、およびプレーンテキストなどの他の形式に変換することをサポートしていることです。 この機能は、複数の形式でドキュメントを表示する必要があるアプリケーションや、HTML にドキュメントコンテンツを表示する必要がある Web アプリケーションにとって不可欠です。 包括的な書式設定オプション: IronWord は幅広い書式設定機能を提供し、開発者がテキストスタイルを適用する、段落の配置を追加する、テーブルや画像などの要素を挿入することができます。 これらのオプションにより、IronWord によって生成または変更されたドキュメントが必要な視覚的および構造的基準を満たしていることが保証されます。 .NET プロジェクトとの容易な統合: IronWord は .NET アプリケーションを念頭に置いて設計されており、NuGet を通じて任意の .NET プロジェクトに簡単に統合できます。 その API は .NET 開発者に直感的に設計されており、Word ドキュメントを使い始めるのが簡単です。 クロスプラットフォームの互換性: IronWord はクロスプラットフォーム開発をサポートしており、さまざまなオペレーティングシステムを対象としたアプリケーションでの使用に適しています。 これは、Windows オペレーティング システムと Linux オペレーティング システムの両方で動作させたり、クラウド環境で動作させたりする必要があるプロジェクトに特に価値があります。 4. Visual Studio での .NET プロジェクトの作成 4.1 Visual Studio で開く まず、Microsoft Visual Studio を起動します。 アプリケーションを開くと、スタートウィンドウが表示されます。 このウィンドウには、既存のプロジェクトを開いたり、新しいプロジェクトを作成したりするためのさまざまなオプションが用意されています。 弊用のために、新しいプロジェクトの開始に焦点を当てます。 4.2 プロジェクトタイプの選択 新しいプロジェクトを作成するオプションをクリックした後、Visual Studio はテンプレートのリストを提示します。 先に進むには、コンソール アプリプロジェクトを選択します。 4.3 プロジェクトの構成 希望のプロジェクトテンプレートを選択したら、「次へ」をクリックしてプロジェクト構成画面に進みます。 ここでは、プロジェクトに関する基本情報を指定する必要があります。 これには、プロジェクト名の指定や、プログラムファイルフォルダのようにプロジェクトファイルが保存される場所の選択が含まれます。 次のダイアログボックスには、ターゲットフレームワークの選択があります。 選択する .NET フレームワークは、アプリケーション用のライブラリと API を決定し、その互換性と機能性に影響を与えます。 アプリケーションで実装を計画している機能をサポートするフレームワークバージョンを選択し、Visual Studio のツールを活用して最適化された開発体験を実現してください。 4.4 プロジェクトの作成 必要な情報を入力し、プロジェクトの要件を満たすようにすべての設定が正しく調整されていることを確認したら、最後のステップとしてプロジェクトを作成します。 これは、「作成」ボタンをクリックして実現されます。 Visual Studio は、選択したテンプレートと構成に基づいて新しいプロジェクトを初期化します。 このプロセスには数分かかる場合があります。その後、新しい .NET プロジェクトが開いて開発の準備が整います。 5. IronWord ライブラリのインストール このセクションでは、NuGet パッケージマネージャ、Visual Studio コマンドライン、および NuGet の Web ページから直接ダウンロードして、プロジェクトに IronWord ライブラリを組み込む方法について掘り下げて説明します。 5.1 NuGet パッケージマネージャを使用する NuGet パッケージマネージャーは、ライブラリやツールをシームレスにインストールするための Visual Studio 内のユーザー フレンドリーなインターフェイスです。 この方法を使用して IronWord ライブラリをインストールするには、次の手順に従います。 NuGet パッケージマネージャを開く: プロジェクトを開いた状態で、ソリューション エクスプローラーのプロジェクト名を右クリックして、コンテキスト メニューから「NuGet パッケージの管理...」を選択します。 この操作により、NuGet パッケージマネージャーウィンドウが開きます。 IronWord を検索する: NuGet パッケージマネージャ ウィンドウで、「参照」タブに移動します。 検索ボックスを使用して、"IronWord" を入力し、Enter を押して IronWord ライブラリを検索します。 IronWord をインストールする: 検索結果から、IronWord パッケージを選択します。 詳細な説明とバージョン情報が表示されます。 プロジェクト要件に合ったバージョンを選択し、「インストール」ボタンをクリックします。 Visual Studio は、ライブラリのダウンロードとインストールを処理し、プロジェクト参照を適切に更新します。 5.2 Visual Studio コマンドラインの使用 コマンドラインツールを使用することを好む場合、Visual Studio は NuGetパッケージを管理するための PowerShell インターフェースであるパッケージ マネージャ コンソールを提供します。 パッケージ マネージャ コンソールにアクセスする: Visual Studio のメインメニューから「ツール」>「NuGet パッケージマネージャー」>「パッケージ マネージャ コンソール」に移動します。 IronWord をインストールする: コンソールに次のコマンドを入力し、Enter キーを押します。 Install-Package IronWord このコマンドは、IronWord ライブラリの最新バージョンを取得してプロジェクトに組み込みます。 -Version パラメータの後にバージョン番号を追加して特定のバージョンを指定できます。 5.3 NuGet Webページからの直接ダウンロード プロジェクトのライブラリを手動で管理することを好む場合は、NuGet Web サイトから IronWord パッケージを直接ダウンロードしてプロジェクトに追加できます。 パッケージをダウンロードする: nuget.org にアクセスし、IronWord パッケージを検索します。 パッケージ ページで、ダウンロード リンクを見つけて、.nupkg ファイルを取得し、コンピュータに保存します。 プロジェクトに追加する: ダウンロードしたら、パッケージを手動でプロジェクトに追加できます。 このプロセスには通常、.nupkg ファイルを抽出し、その中のアセンブリをプロジェクトに追加する作業が含まれます。 ただし、上記で説明した NuGet パッケージ マネージャまたは Visual Studio コマンドラインを使用する方が一般的に簡単でエラーが少ないです。 6. Microsoft.Office.Interop.Wordのインストール このライブラリは、さまざまな開発者の好みや要件に合わせたアプローチでプロジェクトに追加できます。 6.1 NuGet パッケージマネージャを使用する Visual Studio の NuGet パッケージ マネージャは、最も簡単な方法であるため、プロジェクトに Microsoft.Office.Interop.Word ライブラリを追加するための方法です。 次の手順に従います。 NuGet パッケージマネージャを開く: Visual Studio でプロジェクトを開き、ソリューション エクスプローラーでプロジェクト名を右クリックします。 コンテキスト メニューから「NuGet パッケージの管理...」を選択して、NuGet パッケージマネージャ ウィンドウを開きます。 ライブラリの検索: NuGet パッケージマネージャ ウィンドウで、「参照」タブに切り替え、検索ボックスに「Microsoft.Office.Interop.Word」と入力します。 Enter キーを押して検索を開始します。 パッケージのインストール: 検索結果から「Microsoft.Office.Interop.Word」パッケージを選択します。 提供されたバージョン情報と説明を確認して、プロジェクトの要件に合うか確認します。 「インストール」ボタンをクリックして、ライブラリをプロジェクトに追加します。 Visual Studio はパッケージのダウンロードとインストールを処理し、必要なアセンブリが含まれるようにプロジェクト参照を更新します。 6.2 Visual Studio コマンドラインの使用 Visual Studio に搭載されたコマンドラインインターフェイスであるパッケージ マネージャ コンソールを使用することで、Microsoft.Office.Interop.Word ライブラリをインストールすることもできます。 パッケージ マネージャ コンソールにアクセスする: Visual Studio のメインメニューから「ツール」>「NuGet パッケージマネージャ」>「パッケージ マネージャ コンソール」に移動します。 インストールコマンドを実行する: コンソールに次のコマンドを入力し、Enter キーを押します。 Install-Package Microsoft.Office.Interop.Word このコマンドは、ライブラリの最新バージョンをフェッチしてプロジェクトに統合するように Visual Studio に指示します。 ライブラリの特定のバージョンが必要な場合は、目的のバージョン番号の後に -Version のパラメータを追加して指定することができます。 6.3 NuGet Webページからの直接ダウンロード プロジェクト依存関係の手動管理を好む開発者は、Microsoft.Office.Interop.Word ライブラリを NuGet Webサイトから直接ダウンロードできます。 パッケージのダウンロード: nuget.org にアクセスし、「Microsoft.Office.Interop.Word」を検索します。 パッケージページでは、ダウンロード リンクを見つけて、.nupkg ファイルを取得し、既知の場所に保存します。コンピュータ。 パッケージを手動でプロジェクトに追加する: ダウンロードした後、.nupkg ファイルをプロジェクトに手動で追加できます。 通常、ファイルを抽出し、抽出されたアセンブリへの参照をプロジェクトに追加する作業が含まれます。 ただし、簡便性と潜在的なエラーを最小限に抑えるためには、NuGet パッケージマネージャまたは Visual Studio コマンドラインを利用することをお勧めします。 7. IronWord と Microsoft.Office.Interop.Word の高度な機能の比較 7.1 IronWordの高度な機能 7.1.1 Word ドキュメントの読み取りと編集 IronWord は、Word ドキュメントの修正 に対応しています。 これには、既存のドキュメントを開いたり、変更を加えたり、その変更を元のドキュメントや新しいファイルに保存したりすることが含まれます。この機能は、ユーザー入力や他のソースからのデータに基づいてドキュメントを更新する必要があるアプリケーションにとって不可欠です。 using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument("my_new_document.docx"); // Insert new text content into the document document.AddText("This is a demonstration of modifying content with IronWord."); // Save the document with a new filename document.SaveAs("updated_document.docx"); using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument("my_new_document.docx"); // Insert new text content into the document document.AddText("This is a demonstration of modifying content with IronWord."); // Save the document with a new filename document.SaveAs("updated_document.docx"); Imports IronWord Imports IronWord.Models ' Initialize a new Word document Private document As New WordDocument("my_new_document.docx") ' Insert new text content into the document document.AddText("This is a demonstration of modifying content with IronWord.") ' Save the document with a new filename document.SaveAs("updated_document.docx") $vbLabelText $csharpLabel 7.1.2 ページ設定の編集 IronWord は、ドキュメントの用紙サイズを変更でき、A4、レター、リーガルなどのさまざまな標準に対応しています。 ドキュメントの要件に応じて、配置を縦向きと横向きの間で調整できます。 7.1.3 段落の追加 段落の追加 は IronWord では簡単で、アプリケーションのロジックに基づいてプログラムによって動的にテキストを挿入できます。 using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument(); // Insert text into the document document.AddText("Exploring IronWord Capabilities"); // Save the document to a new file document.SaveAs("updated_ironword_document.docx"); using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument(); // Insert text into the document document.AddText("Exploring IronWord Capabilities"); // Save the document to a new file document.SaveAs("updated_ironword_document.docx"); Imports IronWord Imports IronWord.Models ' Initialize a new Word document Private document As New WordDocument() ' Insert text into the document document.AddText("Exploring IronWord Capabilities") ' Save the document to a new file document.SaveAs("updated_ironword_document.docx") $vbLabelText $csharpLabel 7.1.4 テキストランの追加と削除 テキストランは、共通のプロパティを持つテキストのセクションを表します。 IronWord は、これらを追加および削除することができ、テキストのセグメンテーションとプロパティの管理を開発者に提供します。 7.1.5 画像の追加 IronWord は、ドキュメントに画像を追加することをサポートしており、位置、折り返し、およびサイズを指定します。これは、ドキュメントの視覚的な魅力と効果を高めます。 using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument(); // Setup an image IronWord.Models.Image img = new IronWord.Models.Image("updated_image.jpg"); img.Width = 250; // Width in pixels img.Height = 250; // Height in pixels // Create a paragraph to contain the image Paragraph para = new Paragraph(); // Incorporate an image into the paragraph para.AddImage(img); // Add the paragraph to the document document.AddParagraph(para); // Save the document with a new name document.SaveAs("updated_save_document.docx"); using IronWord; using IronWord.Models; // Initialize a new Word document WordDocument document = new WordDocument(); // Setup an image IronWord.Models.Image img = new IronWord.Models.Image("updated_image.jpg"); img.Width = 250; // Width in pixels img.Height = 250; // Height in pixels // Create a paragraph to contain the image Paragraph para = new Paragraph(); // Incorporate an image into the paragraph para.AddImage(img); // Add the paragraph to the document document.AddParagraph(para); // Save the document with a new name document.SaveAs("updated_save_document.docx"); Imports IronWord Imports IronWord.Models ' Initialize a new Word document Private document As New WordDocument() ' Setup an image Private img As New IronWord.Models.Image("updated_image.jpg") img.Width = 250 ' Width in pixels img.Height = 250 ' Height in pixels ' Create a paragraph to contain the image Dim para As New Paragraph() ' Incorporate an image into the paragraph para.AddImage(img) ' Add the paragraph to the document document.AddParagraph(para) ' Save the document with a new name document.SaveAs("updated_save_document.docx") $vbLabelText $csharpLabel 7.1.6 図形の追加 図形は、IronWord でドキュメントに追加でき、図形の種類、サイズ、位置、回転を設定できます。 これにより、情報を強調表示したり、装飾要素を追加してビジュアルに関心を持たせることができます。 7.1.7 スタイリングの設定 IronWord におけるスタイリングオプション は広範で、フォントファミリーとサイズ、カラー、および太字、イタリック、取り消し線、下線、上付き、下付きなどのテキスト装飾を網羅しています。 このレベルの制御は、ブランド標準の維持とドキュメントの読みやすさの確保に重要です。 using IronSoftware.Drawing; using IronWord; using IronWord.Models; using Color = IronSoftware.Drawing.Color; // Initialize WordDocument with a file WordDocument document = new WordDocument("updated_document.docx"); // Create a TextRun with modifications TextRun modifiedTextRun = new TextRun { Text = "Updated text with IronWord", Style = new TextStyle { FontFamily = "Arial", FontSize = 48, // Adjusted font size TextColor = new IronColor(Color.Blue), IsBold = false, IsItalic = false, IsUnderline = false, IsSuperscript = true, IsStrikethrough = false, IsSubscript = true } }; // Create a paragraph and add the TextRun Paragraph newParagraph = new Paragraph(); newParagraph.AddTextRun(modifiedTextRun); // Add the paragraph to the document document.AddParagraph(newParagraph); // Save the document with a new name document.SaveAs("updated_save_document.docx"); using IronSoftware.Drawing; using IronWord; using IronWord.Models; using Color = IronSoftware.Drawing.Color; // Initialize WordDocument with a file WordDocument document = new WordDocument("updated_document.docx"); // Create a TextRun with modifications TextRun modifiedTextRun = new TextRun { Text = "Updated text with IronWord", Style = new TextStyle { FontFamily = "Arial", FontSize = 48, // Adjusted font size TextColor = new IronColor(Color.Blue), IsBold = false, IsItalic = false, IsUnderline = false, IsSuperscript = true, IsStrikethrough = false, IsSubscript = true } }; // Create a paragraph and add the TextRun Paragraph newParagraph = new Paragraph(); newParagraph.AddTextRun(modifiedTextRun); // Add the paragraph to the document document.AddParagraph(newParagraph); // Save the document with a new name document.SaveAs("updated_save_document.docx"); Imports IronSoftware.Drawing Imports IronWord Imports IronWord.Models Imports Color = IronSoftware.Drawing.Color ' Initialize WordDocument with a file Private document As New WordDocument("updated_document.docx") ' Create a TextRun with modifications Private modifiedTextRun As New TextRun With { .Text = "Updated text with IronWord", .Style = New TextStyle With { .FontFamily = "Arial", .FontSize = 48, .TextColor = New IronColor(Color.Blue), .IsBold = False, .IsItalic = False, .IsUnderline = False, .IsSuperscript = True, .IsStrikethrough = False, .IsSubscript = True } } ' Create a paragraph and add the TextRun Private newParagraph As New Paragraph() newParagraph.AddTextRun(modifiedTextRun) ' Add the paragraph to the document document.AddParagraph(newParagraph) ' Save the document with a new name document.SaveAs("updated_save_document.docx") $vbLabelText $csharpLabel 7.1.8 整列の設定 IronWord は、ドキュメント内のテキストの位置を設定することをサポートし、左揃え、中央揃え、右揃え、両端揃えをサポートしています。 これは、 aesthetics と読みやすさの両方にとって重要です。 7.1.10 テーブルの追加 テーブルは、多くのドキュメントの重要なコンポーネントであり、データと情報の整理に使用されます。 IronWord はテーブルの追加とその構造を操作する機能を提供し、行と列の追加や削除が可能です。 テーブル セルのコンテンツ操作は IronWord では簡単に行え、アプリケーションのニーズに基づいて動的コンテンツを挿入できます。 IronWord では、テーブル セルを結合および分割する機能が提供されており、複雑なデータ プレゼンテーションの要件に対応したテーブル レイアウトのカスタマイズに役立ちます。 using IronWord; using IronWord.Models; // Create a table cell TableCell cell = new TableCell(); TextRun textRun = new TextRun(); textRun.Text = "Updated content"; // Changed the text content // Add a TextRun to the cell cell.AddContent(new Paragraph(textRun)); // Configure border style BorderStyle borderStyle = new BorderStyle { BorderColor = new IronColor(IronSoftware.Drawing.Color.Blue), // Changed border color to blue BorderValue = IronWord.Models.Enums.BorderValues.Double, // Changed border style to double BorderSize = 3 // Adjusted border size to 3 }; // Configure table border TableBorders tableBorders = new TableBorders { TopBorder = borderStyle, RightBorder = borderStyle, BottomBorder = borderStyle, LeftBorder = borderStyle, }; // Assign borders to the cell cell.Borders = tableBorders; // Create a row and add the cell TableRow row = new TableRow(); row.AddCell(cell); row.AddCell(cell); // Create a table and add the row Table table = new Table(); table.AddRow(row); // Create a new Word document from the table WordDocument doc = new WordDocument(table); // Export the Word document doc.SaveAs("UpdatedDocument.docx"); using IronWord; using IronWord.Models; // Create a table cell TableCell cell = new TableCell(); TextRun textRun = new TextRun(); textRun.Text = "Updated content"; // Changed the text content // Add a TextRun to the cell cell.AddContent(new Paragraph(textRun)); // Configure border style BorderStyle borderStyle = new BorderStyle { BorderColor = new IronColor(IronSoftware.Drawing.Color.Blue), // Changed border color to blue BorderValue = IronWord.Models.Enums.BorderValues.Double, // Changed border style to double BorderSize = 3 // Adjusted border size to 3 }; // Configure table border TableBorders tableBorders = new TableBorders { TopBorder = borderStyle, RightBorder = borderStyle, BottomBorder = borderStyle, LeftBorder = borderStyle, }; // Assign borders to the cell cell.Borders = tableBorders; // Create a row and add the cell TableRow row = new TableRow(); row.AddCell(cell); row.AddCell(cell); // Create a table and add the row Table table = new Table(); table.AddRow(row); // Create a new Word document from the table WordDocument doc = new WordDocument(table); // Export the Word document doc.SaveAs("UpdatedDocument.docx"); Imports IronWord Imports IronWord.Models ' Create a table cell Private cell As New TableCell() Private textRun As New TextRun() textRun.Text = "Updated content" ' Changed the text content ' Add a TextRun to the cell cell.AddContent(New Paragraph(textRun)) ' Configure border style Dim borderStyle As New BorderStyle With { .BorderColor = New IronColor(IronSoftware.Drawing.Color.Blue), .BorderValue = IronWord.Models.Enums.BorderValues.Double, .BorderSize = 3 } ' Configure table border Dim tableBorders As New TableBorders With { .TopBorder = borderStyle, .RightBorder = borderStyle, .BottomBorder = borderStyle, .LeftBorder = borderStyle } ' Assign borders to the cell cell.Borders = tableBorders ' Create a row and add the cell Dim row As New TableRow() row.AddCell(cell) row.AddCell(cell) ' Create a table and add the row Dim table As New Table() table.AddRow(row) ' Create a new Word document from the table Dim doc As New WordDocument(table) ' Export the Word document doc.SaveAs("UpdatedDocument.docx") $vbLabelText $csharpLabel 7.2 Microsoft.Office.Interop.Wordの特定の高度な機能 Microsoft.Office.Interop.Word は、Word ドキュメントとの深い統合を可能にし、開発者が Word の豊富な機能をプログラム的に活用できるようにします。 以下は、前述の一般的な機能とは異なる Microsoft.Office.Interop.Word が提供する特定の高度な機能です。 7.2.1 コンテンツ コントロール Microsoft.Office.Interop.Word は、リッチテキストボックス、コンボボックス、日付ピッカー、およびチェックボックスを含むコンテンツコントロールの追加と操作をサポートします。 これらのコントロールは、セットされたテンプレート内でユーザーが情報を入力または選択できる構造化されたインタラクティブなドキュメントの作成に使用できます。 using Microsoft.Office.Interop.Word; // Create a new Word application and document var application = new Application(); var document = application.Documents.Add(); // Add a combo box content control object missing = System.Reflection.Missing.Value; var cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, ref missing); cc.Title = "Choose an option"; cc.DropdownListEntries.Add("Option 1", "1"); cc.DropdownListEntries.Add("Option 2", "2"); using Microsoft.Office.Interop.Word; // Create a new Word application and document var application = new Application(); var document = application.Documents.Add(); // Add a combo box content control object missing = System.Reflection.Missing.Value; var cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, ref missing); cc.Title = "Choose an option"; cc.DropdownListEntries.Add("Option 1", "1"); cc.DropdownListEntries.Add("Option 2", "2"); Imports Microsoft.Office.Interop.Word ' Create a new Word application and document Private application = New Application() Private document = application.Documents.Add() ' Add a combo box content control Private missing As Object = System.Reflection.Missing.Value Private cc = document.ContentControls.Add(WdContentControlType.wdContentControlComboBox, missing) cc.Title = "Choose an option" cc.DropdownListEntries.Add("Option 1", "1") cc.DropdownListEntries.Add("Option 2", "2") $vbLabelText $csharpLabel 7.2.2 差し込み印刷 差し込み印刷プロセスの自動化を行い、スプレッドシートやデータベースのようなデータソースと連携して、個別の手紙、ラベル、または電子メールを一括で生成します。 using Microsoft.Office.Interop.Word; // Create a new document for mail merge var mailMergeDoc = application.Documents.Add(); // Open the data source for the mail merge mailMergeDoc.MailMerge.OpenDataSource("path\\to\\datasource.xlsx"); // Execute the mail merge mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument; mailMergeDoc.MailMerge.Execute(false); using Microsoft.Office.Interop.Word; // Create a new document for mail merge var mailMergeDoc = application.Documents.Add(); // Open the data source for the mail merge mailMergeDoc.MailMerge.OpenDataSource("path\\to\\datasource.xlsx"); // Execute the mail merge mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument; mailMergeDoc.MailMerge.Execute(false); Imports Microsoft.Office.Interop.Word ' Create a new document for mail merge Private mailMergeDoc = application.Documents.Add() ' Open the data source for the mail merge mailMergeDoc.MailMerge.OpenDataSource("path\to\datasource.xlsx") ' Execute the mail merge mailMergeDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToNewDocument mailMergeDoc.MailMerge.Execute(False) $vbLabelText $csharpLabel この機能は、大量のカスタマイズされた通信や文書の作成に欠かせないものです。 7.2.3 テキスト校正とコメント Word の変更履歴とコメント機能をコードを用いて有効化し、操作します。 using Microsoft.Office.Interop.Word; // Enable track changes document.TrackRevisions = true; // Add a comment to the first paragraph object start = 0; object end = 0; Range range = document.Paragraphs[1].Range; document.Comments.Add(range, "This is a comment."); using Microsoft.Office.Interop.Word; // Enable track changes document.TrackRevisions = true; // Add a comment to the first paragraph object start = 0; object end = 0; Range range = document.Paragraphs[1].Range; document.Comments.Add(range, "This is a comment."); Imports Microsoft.Office.Interop.Word ' Enable track changes document.TrackRevisions = True ' Add a comment to the first paragraph Dim start As Object = 0 Dim [end] As Object = 0 Dim range As Range = document.Paragraphs(1).Range document.Comments.Add(range, "This is a comment.") $vbLabelText $csharpLabel この機能は、共同編集、ドキュメントレビュー、または時間の経過に伴う変更の監査が必要なアプリケーションにとって重要です。 7.2.4 ヘッダーとフッター ページ番号、日付、またはカスタムテキストを含むヘッダーとフッターを動的に操作します。 using Microsoft.Office.Interop.Word; // Iterate through sections in the document and set headers and footers foreach (Section section in document.Sections) { // Set text for primary header section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Header Text"; // Add page numbers to primary footer section.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add(); } using Microsoft.Office.Interop.Word; // Iterate through sections in the document and set headers and footers foreach (Section section in document.Sections) { // Set text for primary header section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Header Text"; // Add page numbers to primary footer section.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add(); } Imports Microsoft.Office.Interop.Word ' Iterate through sections in the document and set headers and footers For Each section As Section In document.Sections ' Set text for primary header section.Headers(WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Text = "Header Text" ' Add page numbers to primary footer section.Footers(WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.Add() Next section $vbLabelText $csharpLabel これは、一貫したブランディングおよびナビゲーションアシストを備えたプロフェッショナルなドキュメントを作成するために重要です。 7.2.5 目次と索引 ドキュメントの見出しまたは印タグに基づいて目次または索引の生成および更新を行います。 using Microsoft.Office.Interop.Word; // Add a table of contents to the document var toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel: 1, LowerHeadingLevel: 3, UseHyperlinks: true); // Add an index to the document var index = document.Indexes.Add(document.Content); using Microsoft.Office.Interop.Word; // Add a table of contents to the document var toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel: 1, LowerHeadingLevel: 3, UseHyperlinks: true); // Add an index to the document var index = document.Indexes.Add(document.Content); Imports Microsoft.Office.Interop.Word ' Add a table of contents to the document Private toc = document.TablesOfContents.Add(document.Content, UpperHeadingLevel:= 1, LowerHeadingLevel:= 3, UseHyperlinks:= True) ' Add an index to the document Private index = document.Indexes.Add(document.Content) $vbLabelText $csharpLabel これは、特に長いレポートや本のようなナビゲート可能なプロフェッショナルなドキュメントを作成するための鍵です。 7.2.6 オブジェクトの埋め込みとリンク Excel グラフや PowerPoint プレゼンテーションなどの外部オブジェクトを Word ドキュメントに埋め込んだりリンクしたりします。 using Microsoft.Office.Interop.Word; // Embed an Excel sheet into the document object missing = System.Reflection.Missing.Value; document.InlineShapes.AddOLEObject( ClassType: "Excel.Sheet", FileName: "path\\to\\excel.xlsx", LinkToFile: false, DisplayAsIcon: false, IconFileName: ref missing, IconIndex: ref missing, IconLabel: ref missing, Anchor: ref missing ); using Microsoft.Office.Interop.Word; // Embed an Excel sheet into the document object missing = System.Reflection.Missing.Value; document.InlineShapes.AddOLEObject( ClassType: "Excel.Sheet", FileName: "path\\to\\excel.xlsx", LinkToFile: false, DisplayAsIcon: false, IconFileName: ref missing, IconIndex: ref missing, IconLabel: ref missing, Anchor: ref missing ); Imports Microsoft.Office.Interop.Word ' Embed an Excel sheet into the document Private missing As Object = System.Reflection.Missing.Value document.InlineShapes.AddOLEObject(ClassType:= "Excel.Sheet", FileName:= "path\to\excel.xlsx", LinkToFile:= False, DisplayAsIcon:= False, IconFileName:= missing, IconIndex:= missing, IconLabel:= missing, Anchor:= missing) $vbLabelText $csharpLabel この機能により、ソース ファイルやドキュメント内の情報を直接反映する動的なコンテンツが利用可能になります。 8. ドキュメントとサポート 8.1 IronWord のドキュメントとサポート IronWord はその完全な潜在能力を活用するために開発者を支援するために充実したドキュメントとサポートを提供します。 このドキュメントには、詳細な開始ガイド、機能の概要、クイックスタート例、および包括的な API リファレンスを含む広範なリソースが含まれています。 IronWord のサポートは強力であり、開発者が問題を迅速に解決できるようにする技術援助を提供します。 サポートフレームワークには、問い合わせを受け付け、問題を解決する専任チームが含まれています。 8.2 Microsoft.Office.Interop.Word のドキュメントとサポート Microsoft.Office.Interop.Word は Microsoft の広範なドキュメントとサポートに支えられて、.NET 開発者に Word ドキュメントとプログラム的にやり取りするためのツールを提供します。 このドキュメントには、初心者向けガイドから高度な例、詳細な API 情報、実用的なユースケースまで、すべてが含まれています。 サポートのために、Microsoft は、直接の技術援助やコミュニティ フォーラム、Stack Overflow といったピアサポートなど、複数のチャンネルを提供します。 GitHub も問題の報告と改善の提案において重要です。 定期的な更新により、ライブラリは新しい Word バージョンと互換性が保たれ、Microsoft の開発者ニーズへの継続的なコミットメントを反映しています。 9. ライセンスモデル 9.1 IronWord ライセンス IronWord は無料および商用の両方のライセンスオプションを提供します。 ライトライセンス: $liteLicense USD 1開発者 1場所 1プロジェクト メールサポート プラスライセンス: $plusLicense USD 最大3開発者 3場所 3プロジェクト メール(24/7)およびチャットサポート 電話サポート プロフェッショナルライセンス: $professionalLicense USD 最大10開発者 10場所 10プロジェクト メール(24/7)、チャット、および電話サポート 画面共有サポート すべての商用ライセンスには、優先サポートと更新が含まれています。 また、製品環境でのすべての機能のテストを行うための無料トライアルも提供しています。 9.2 Microsoft.Office.Interop.Word ライセンス Microsoft.Office.Interop.Wordのライセンスは、Microsoft Office スイートに関連付けられています。Interopライブラリ自体には別途ライセンスは必要ありません Microsoft Office に含まれています。Microsoft.Office.Interop.Word をアプリケーションで使用するには、デプロイ環境に有効な Microsoft Office ライセンス (Word を含む) が必要です。 コストは、選択した特定の Office スイート バージョンとライセンス契約に依存し、個別のライセンスからビジネス向けのボリュームライセンスに至るまで異なります。 正確な価格に関しては、Microsoft の公式ウェブサイトを参照するか、Microsoft の営業担当者にお問い合わせください。 10. 結論 IronWord と Microsoft.Office.Interop.Word の比較では、機能、使いやすさ、プラットフォーム互換性、ライセンスなどさまざまな側面を調べてきました。 IronWord は、Word ドキュメント操作の柔軟でクロスプラットフォームなソリューションを求める開発者には特に強力な候補として浮上します。 Microsoft Office に依存せずに動作できることで、IronWord はドキュメント処理へのスムーズなアプローチを提供し、さまざまな環境で実行されるアプリケーションに理想的な選択肢になります。 その包括的な機能セットに加え、Microsoft Word のインストールを不要にする利便性により、特に展開のシンプルさと幅広い互換性が重要な要件であるシナリオで、IronWord にエッジが与えられます。 IronWord を購入したい場合は、ライセンスページに移動してください。 ご注意Microsoft.Office.Interop.Word はそれぞれの所有者の登録商標です。 すべての製品名、ロゴ、およびブランドは各所有者の所有物です。 比較は情報提供のみを目的としており、執筆時点で公開されている情報を反映しています。 よくある質問 Microsoft Word をインストールせずに .NET で Word ドキュメントを作成、編集、フォーマットするにはどうすれば良いですか? IronWord を使用すれば、スタンドアロンの .NET ライブラリとしてドキュメント操作やさまざまなフォーマットへの変換、包括的なフォーマットオプションを提供し、Microsoft Word をインストールする必要はありません。 Microsoft.Office.Interop.Word と IronWord の .NET プロジェクトでの違いは何ですか? Microsoft.Office.Interop.Word は Microsoft Word のインストールを必要とし、Word の機能と深く統合されています。IronWord はスタンドアロンライブラリで、Word を必要とせず、クロスプラットフォームの開発をサポートし、サーバーやクラウドのコンテキストにおいてより柔軟です。 .NET ライブラリを Visual Studio を使用して Word ドキュメント処理にインストールするにはどうすれば良いですか? IronWord と Microsoft.Office.Interop.Word の両方は、Visual Studio の NuGet パッケージマネージャー、Visual Studio コマンドライン、または NuGet ウェブサイトから直接ダウンロードしてインストールできます。 IronWord のライセンスオプションにはどのようなものがありますか? IronWord は無料ライセンスと商用ライセンスの両方を提供しており、Lite、Plus、および Professional の各レベルは、開発者、場所、プロジェクトの制限が異なります。 Microsoft.Office.Interop.Word はどのように Microsoft Word の機能と統合されますか? Microsoft.Office.Interop.Word は、.NET アプリケーションがドキュメントの作成、編集、フォーマット、コンテンツコントロール、差し込み印刷、その他の高度な機能を含む Word の完全な機能を活用できるようにし、Microsoft Word のインストールを必要とします。 どのライブラリが .NET のクロスプラットフォーム開発により適していますか? IronWord は、Microsoft Word がインストールされていることを必要とせず、異なるオペレーティングシステム上のアプリケーションをサポートするため、クロスプラットフォーム開発により適しています。 IronWord は、ドキュメント操作にどのような高度な機能を提供しますか? IronWord は、Microsoft Word を必要とせずに、Word ドキュメントの読み取りと編集、ページの設定、段落、画像、テーブルの追加、およびスタイルや整列の適用といった高度な機能を提供します。 IronWord と Microsoft.Office.Interop.Word を選ぶ際の重要な考慮事項は何ですか? 環境に Microsoft Word がすでにインストールされているかどうか、また、Word の機能と深く統合する必要があるかを考慮してください。IronWord は、Word なしでサーバーやクラウドアプリケーションに柔軟性をもたらす一方で、Microsoft.Office.Interop.Word は、Word 機能への包括的なアクセスを提供しながら、Word のインストールを必要とします。 Jordi Bardia 今すぐエンジニアリングチームとチャット ソフトウェアエンジニア Jordiは、最も得意な言語がPython、C#、C++であり、Iron Softwareでそのスキルを発揮していない時は、ゲームプログラミングをしています。製品テスト、製品開発、研究の責任を分担し、Jordiは継続的な製品改善において多大な価値を追加しています。この多様な経験は彼を挑戦させ続け、興味を持たせており、Iron Softwareで働くことの好きな側面の一つだと言います。Jordiはフロリダ州マイアミで育ち、フロリダ大学でコンピュータサイエンスと統計学を学びました。 関連する記事 更新日 7月 28, 2025 IronWordとAspose Words For .NETの比較 Aspose.Word を多用途のツールとして考え、複数のドキュメント形式を扱うのに適しており、複雑なドキュメントの作成と操作のための広範な機能を提供します 詳しく読む IronWordとAspose Words For .NETの...
更新日 7月 28, 2025 IronWordとAspose Words For .NETの比較 Aspose.Word を多用途のツールとして考え、複数のドキュメント形式を扱うのに適しており、複雑なドキュメントの作成と操作のための広範な機能を提供します 詳しく読む