フッターコンテンツにスキップ
IRONWORDの使用方法

.NETワードAPI(開発者向けの動作)

.NET Word APIは、開発者にWordドキュメントを変換し、アプリケーション内でMS Wordドキュメントと対話および操作するための強力なツールを提供します。 このAPIは、Microsoft Wordドキュメントを扱うプロセスを簡素化するように設計されており、プログラムによってドキュメントを作成、編集、変換、管理することが容易になります。 この記事では、IronWordを探求してそのWordドキュメント操作機能を理解します。

IronWordの紹介

IronWordは.NET Word APIエコシステム内の.NET Wordライブラリであり、.NETアプリケーションでMicrosoft Wordドキュメントを処理する開発者向けに特に設計されています。 IronWordを使用すると、開発者はサーバーまたはクライアントマシンにMicrosoft Wordをインストールする必要なく、Wordドキュメントを簡単に読み書きおよび修正できます。 この機能は、報告書、請求書、郵便物結合機能を通じたパーソナライズされた通信など、ドキュメントプロセスの自動化が必要なアプリケーションに特に有益です。

IronWordの機能

IronWordは、Wordドキュメント操作のさまざまな側面に対応する包括的な機能を提供します。 各機能セットを探求し、それらがどのように複数のドキュメントの操作と結合を可能にするかを、「ドキュメント構造」と「ドキュメント要素」に分類して説明します。

ドキュメント構造

Wordの読み取りと編集: IronWordを使用すると、Wordドキュメントから特定の情報を引き出すことができ、編集や再利用のためのテキストの抽出や、他の場所で使用する必要がある画像の取得が可能です。 この機能は、Wordドキュメントを結合し、既存のDOCXファイルに含まれる情報を処理することを目的としたアプリケーションにとって重要です。

複数のフォーマット: IronWordは多様なファイル形式をサポートしており、.NETアプリケーション内でのWordドキュメントの変換においてその有用性を高めています。

ページ設定の編集: Wordドキュメントの物理的レイアウトの調整はIronWordで簡単です。 さまざまなMS Wordファイルの用紙サイズを標準またはカスタムの寸法に調整し、ドキュメントの異なるセクションの向きを変更し、適切な整列を確保するためにマージンを設定し、また美観を考慮してセクションを強調するために背景色を変更することができます。

段落の追加: IronWordは、段落内のテキストの追加および削除を可能にし、大きなテキストセクションの編集およびフォーマットに不可欠です。 さらに、画像や図形を直接テキストに挿入して段落を向上させ、デザイン仕様に合わせてスタイルを調整し、洗練された外観のために配置を設定することができます。 項目符号や番号付きリストの追加も、より効果的にコンテンツを整理するのに役立ちます。

using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        // Load docx
        WordDocument doc = new WordDocument();
        // Create and add styled text to a paragraph
        Paragraph paragraph = new Paragraph();

        // Adding regular text
        paragraph.AddTextRun(new TextRun("Exploring text styles within a document."));

        // Adding italic text
        paragraph.AddTextRun(new TextRun("An example in italic.", new TextStyle { IsItalic = true }));

        // Adding bold text
        paragraph.AddTextRun(new TextRun("An example in bold.", new TextStyle { IsBold = true }));

        // Add paragraph to the document and export docx
        doc.AddParagraph(paragraph);
        doc.SaveAs("newdocument.docx");
    }
}
using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        // Load docx
        WordDocument doc = new WordDocument();
        // Create and add styled text to a paragraph
        Paragraph paragraph = new Paragraph();

        // Adding regular text
        paragraph.AddTextRun(new TextRun("Exploring text styles within a document."));

        // Adding italic text
        paragraph.AddTextRun(new TextRun("An example in italic.", new TextStyle { IsItalic = true }));

        // Adding bold text
        paragraph.AddTextRun(new TextRun("An example in bold.", new TextStyle { IsBold = true }));

        // Add paragraph to the document and export docx
        doc.AddParagraph(paragraph);
        doc.SaveAs("newdocument.docx");
    }
}
Imports IronWord
Imports IronWord.Models

Friend Class Program
	Shared Sub Main()
		' Load docx
		Dim doc As New WordDocument()
		' Create and add styled text to a paragraph
		Dim paragraph As New Paragraph()

		' Adding regular text
		paragraph.AddTextRun(New TextRun("Exploring text styles within a document."))

		' Adding italic text
		paragraph.AddTextRun(New TextRun("An example in italic.", New TextStyle With {.IsItalic = True}))

		' Adding bold text
		paragraph.AddTextRun(New TextRun("An example in bold.", New TextStyle With {.IsBold = True}))

		' Add paragraph to the document and export docx
		doc.AddParagraph(paragraph)
		doc.SaveAs("newdocument.docx")
	End Sub
End Class
$vbLabelText   $csharpLabel

表の追加: DOCXファイルの重要な要素である表は、IronWordを使用して簡単に操作でき、動的なドキュメント生成をサポートします。 行と列の追加や削除が可能であり、データ量が変動する動的なドキュメント生成において重要な操作です。 セルの結合および分割により、複雑なテーブルをフォーマットする柔軟性を提供し、境界線やレイアウト寸法をカスタマイズすることで、洗練されたプロフェッショナルな外観を実現します。

using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        // Create a table cell with a paragraph containing text
        TableCell cell = new TableCell(new Paragraph(new TextRun("Sample text")));

        // Configure a common border style for the table
        BorderStyle borderStyle = new BorderStyle
        {
            BorderColor = new IronColor(IronSoftware.Drawing.Color.Black),
            BorderValue = IronWord.Models.Enums.BorderValues.Thick,
            BorderSize = 5
        };

        // Apply the border style to the cell
        cell.Borders = new TableBorders
        {
            TopBorder = borderStyle,
            RightBorder = borderStyle,
            BottomBorder = borderStyle,
            LeftBorder = borderStyle
        };

        // Create a table row and add the same cell twice
        TableRow row = new TableRow();
        row.AddCell(cell);
        row.AddCell(cell);

        // Create a table, add the row, then create and export the Word document
        Table table = new Table();
        table.AddRow(row);
        WordDocument doc = new WordDocument(table);
        doc.SaveAs("Document.docx");
    }
}
using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        // Create a table cell with a paragraph containing text
        TableCell cell = new TableCell(new Paragraph(new TextRun("Sample text")));

        // Configure a common border style for the table
        BorderStyle borderStyle = new BorderStyle
        {
            BorderColor = new IronColor(IronSoftware.Drawing.Color.Black),
            BorderValue = IronWord.Models.Enums.BorderValues.Thick,
            BorderSize = 5
        };

        // Apply the border style to the cell
        cell.Borders = new TableBorders
        {
            TopBorder = borderStyle,
            RightBorder = borderStyle,
            BottomBorder = borderStyle,
            LeftBorder = borderStyle
        };

        // Create a table row and add the same cell twice
        TableRow row = new TableRow();
        row.AddCell(cell);
        row.AddCell(cell);

        // Create a table, add the row, then create and export the Word document
        Table table = new Table();
        table.AddRow(row);
        WordDocument doc = new WordDocument(table);
        doc.SaveAs("Document.docx");
    }
}
Imports IronWord
Imports IronWord.Models

Friend Class Program
	Shared Sub Main()
		' Create a table cell with a paragraph containing text
		Dim cell As New TableCell(New Paragraph(New TextRun("Sample text")))

		' Configure a common border style for the table
		Dim borderStyle As New BorderStyle With {
			.BorderColor = New IronColor(IronSoftware.Drawing.Color.Black),
			.BorderValue = IronWord.Models.Enums.BorderValues.Thick,
			.BorderSize = 5
		}

		' Apply the border style to the cell
		cell.Borders = New TableBorders With {
			.TopBorder = borderStyle,
			.RightBorder = borderStyle,
			.BottomBorder = borderStyle,
			.LeftBorder = borderStyle
		}

		' Create a table row and add the same cell twice
		Dim row As New TableRow()
		row.AddCell(cell)
		row.AddCell(cell)

		' Create a table, add the row, then create and export the Word document
		Dim table As New Table()
		table.AddRow(row)
		Dim doc As New WordDocument(table)
		doc.SaveAs("Document.docx")
	End Sub
End Class
$vbLabelText   $csharpLabel

!.NET Word API (開発者向けの動作方法): 図1 - 表のある出力されたPDF

ドキュメント要素

テキストランの追加: この機能はテキストコンテンツに対する細やかなコントロールに焦点を当てています。 テキストランを追加、追加、分割することができ、これは動的なドキュメント作成にとって重要です。 スタイルオプションは豊富で、フォントファミリー、サイズ、色の変更、太字、イタリックなどのテキスト装飾の追加が含まれます。 テキストランに画像を埋め込むこともでき、リッチで視覚的に魅力的なドキュメントを作成します。

画像の追加: IronWordではWordドキュメント内での包括的な画像操作が可能です。 さまざまなソースから画像をロードし、それらの周りにスムーズにテキストを配置し、レイアウトに合わせて寸法を調整することができます。 位置オフセットを設定し、ドキュメントのコーナーからの距離を設定することで、常に完璧に配置されます。

using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        WordDocument doc = new WordDocument();

        // Load and configure the image
        IronWord.Models.Image image = new IronWord.Models.Image("your-image.jpg")
        {
            Width = 200, // In unit pixels
            Height = 200 // In unit pixels
        };

        // Create paragraph, add image, add paragraph to document, and export
        Paragraph paragraph = new Paragraph();
        paragraph.AddImage(image);

        // Add paragraph containing the image to the document
        doc.AddParagraph(paragraph);
        doc.SaveAs("save_document.docx");
    }
}
using IronWord;
using IronWord.Models;

class Program
{
    static void Main()
    {
        WordDocument doc = new WordDocument();

        // Load and configure the image
        IronWord.Models.Image image = new IronWord.Models.Image("your-image.jpg")
        {
            Width = 200, // In unit pixels
            Height = 200 // In unit pixels
        };

        // Create paragraph, add image, add paragraph to document, and export
        Paragraph paragraph = new Paragraph();
        paragraph.AddImage(image);

        // Add paragraph containing the image to the document
        doc.AddParagraph(paragraph);
        doc.SaveAs("save_document.docx");
    }
}
Imports IronWord
Imports IronWord.Models

Friend Class Program
	Shared Sub Main()
		Dim doc As New WordDocument()

		' Load and configure the image
		Dim image As New IronWord.Models.Image("your-image.jpg") With {
			.Width = 200,
			.Height = 200
		}

		' Create paragraph, add image, add paragraph to document, and export
		Dim paragraph As New Paragraph()
		paragraph.AddImage(image)

		' Add paragraph containing the image to the document
		doc.AddParagraph(paragraph)
		doc.SaveAs("save_document.docx")
	End Sub
End Class
$vbLabelText   $csharpLabel

図形の追加: 図形はドキュメントに重要な視覚効果をもたらし、IronWordを利用して正確に挿入およびカスタマイズできます。 長方形、円、矢印などの図形タイプを設定し、図形周りのテキストの配置方法を決定し、正確な寸法と位置を指定し、望ましい視覚的効果を得るために図形を回転させることもできます。

互換性

.NETバージョンとプロジェクトタイプ

!.NET Word API (開発者向けの動作方法): 図2 - IronWordが互換性のある.NETバージョンとプロジェクトタイプ

IronWordは、.NETエコシステムでの幅広い互換性を念頭に設計されており、.NET Core、.NET Standard、.NET Frameworkを含むさまざまな.NETバージョンでC#、VB.NET、F#をサポートします。 これにより、最新のアプリケーションおよびレガシーアプリケーションの両方での有用性が保障されます。 ライブラリの多用途性は、Blazor、WebForms、Xamarin、MAUI、WPF、コンソールアプリケーションとの統合を介して、ウェブ、モバイル、デスクトップアプリケーションをサポートします。

アプリケーション環境

!.NET Word API (開発者向けの動作方法): 図3 - IronWordが動作可能なアプリケーション環境

アプリケーション環境の観点から、IronWordはWindows、Linux、iOS、Androidプラットフォームに適応でき、Docker、Azure、AWSでのコンテナ化およびクラウド展開の特定のサポートも含まれています。 この広範なサポートにより、さまざまな環境での開発が容易になります。

OSとIDE

!.NET Word API (開発者向けの動作方法): 図4 - IronWordが互換性のあるOSとIDE

IronWordはMicrosoft Visual Studio、ReSharper、Riderなどの主要な統合開発環境(IDE)と互換性があり、開発者にツールの柔軟な選択肢を提供します。 最終的に、さまざまなオペレーティングシステムおよびプロセッサアーキテクチャ(x64、x86、ARM)をサポートし、多様なハードウェア構成での効率的なパフォーマンスを保証します。

ライセンスオプション

!.NET Word API (開発者向けの動作方法): 図5 - IronWordライセンスページ

IronWordは、異なる開発者および組織のニーズに対応するさまざまなライセンスオプションを提供します。 彼らは一度の支払いで再発料金のない永続ライセンスを提供しています。 すべてのライセンスには1年間の製品サポートと更新が含まれています。 ライセンスタイアは、開発者の数、場所、およびプロジェクトに基づいて設計されています。 また、購入前にハンズオン体験ができる無料トライアルを取得することもできます。

Liteライセンス

このオプションは、プロジェクトで一人で働く個別の開発者向けに調整されています。 価格は$liteLicenseで、1つの場所で1人の開発者をカバーします。

Plusライセンス

小規模チームを対象としており、$plusLicenseのこのライセンスは最大3人の開発者を収容し、3つのプロジェクトで3か所での使用に適用されます。

Professionalライセンス

より大規模なチーム向けに、Professionalライセンスは$professionalLicenseで販売され、最大10人の開発者をサポートします。 より大規模な運用を対象として設計されており、プレミアムサポート機能を含んでいます。

結論

最後に、IronWordは、個々の開発者およびチームの多様なニーズに対応する一連のライセンスオプションを提供する、強力で柔軟な.NET Word APIとして浮上します。 その機能は、複数の.NETバージョンおよびプロジェクトタイプにわたる互換性を保証し、Wordドキュメントの効率的な管理と操作を可能にします。

よくある質問

.NETでOffice InteropなしでWordドキュメントを操作するにはどうすればよいですか?

IronWordを使用することで、Microsoft Wordをインストールせずに、プログラムでWordドキュメントを操作できます。Wordドキュメントを効率的に作成、編集、変換するためのツールを提供します。

.NET Word APIのドキュメント処理の主な特徴は何ですか?

.NET Word API、特にIronWordは、Wordドキュメントの読み取りと編集、複数のファイルフォーマットのサポート、ページ設定の編集、段落、表、テキストラン、画像、図形といった要素の追加を行える機能を提供します。

.NETでのレポート生成とメールマージの自動化はどう行われますか?

IronWordは、.NETアプリケーションでのレポート生成やメールマージの自動化に最適です。プログラム的にWordドキュメントを作成および編集し、これらのプロセスを効率化することができます。

.NET Word APIがサポートするプラットフォームはどれですか?

IronWordはWindows、Linux、iOS、およびAndroidを含むさまざまなプラットフォームをサポートしています。また、Docker、Azure、およびAWSでのクラウド展開とも互換性があり、さまざまな環境に柔軟に対応できます。

.NET Word APIを使用してドキュメント構造を変更することは可能ですか?

はい、IronWordは段落、表、およびその他の要素の追加や削除を含む、ドキュメント構造の変更に対する包括的なツールを提供します。ドキュメントのレイアウトを広範にカスタマイズできます。

.NET Word APIのライセンスオプションはどのようなものがありますか?

IronWordは、個人の開発者やさまざまな規模の組織のニーズを満たすためにLite、Plus、Professionalライセンスを含む複数のライセンスオプションを提供しています。

.NET Word APIを購入前に試用することはできますか?

はい、IronWordは無料トライアルを提供しており、開発者は購入の決定前にその機能と能力を探索することができます。

IronWordに対応した開発環境は何ですか?

IronWordは、Blazor、WebForms、Xamarin、MAUI、WPF、およびコンソールアプリケーションを含むさまざまな開発環境と互換性があります。.NET Core、.NET Standard、および.NET Framework全体でC#、VB.NET、F#に対応しています。

Jordi Bardia
ソフトウェアエンジニア
Jordiは、最も得意な言語がPython、C#、C++であり、Iron Softwareでそのスキルを発揮していない時は、ゲームプログラミングをしています。製品テスト、製品開発、研究の責任を分担し、Jordiは継続的な製品改善において多大な価値を追加しています。この多様な経験は彼を挑戦させ続け、興味を持たせており、Iron Softwareで働くことの好きな側面の一つだと言います。Jordiはフロリダ州マイアミで育ち、フロリダ大学でコンピュータサイエンスと統計学を学びました。