IRONWORDの使用

.NET Word API(開発者向けの動作方法)

更新済み 4月 3, 2024
共有:

イントロダクション

について .NET Word API は、Word文書を変換し、アプリケーション内でMS Word文書と対話し、操作するための堅牢なツールを開発者に提供します。 このAPIは、Microsoft Word文書を扱うプロセスを合理化するために設計されており、プログラムによる文書の作成、編集、変換、管理を容易にします。 この記事では IronWord (アイアンワード) ワード文書を操作する機能を理解する。

アイアンワードの紹介

IronWord (アイアンワード) は、.NET Word APIエコシステム内の.NET Wordライブラリで、.NETアプリケーションでMicrosoft Word文書を処理する開発者向けに特別に設計されています。 アイアンワードを使えば、開発者はサーバーやクライアントマシンにマイクロソフト・ワードがインストールされていなくても、簡単にワード文書を読んだり、書いたり、修正したりすることができる。 この機能は、レポートや請求書の作成、メールマージ機能によるパーソナライズされた通信文の作成など、文書処理タスクを自動化する必要があるアプリケーションに特に有益です。

アイアンワードの特徴

IronWord (アイアンワード)はWord文書操作の様々な側面に対応する包括的な機能を提供します。 ここでは、「文書構造」と「文書要素」に分類された各機能を、複数の文書の操作や結合をどのように可能にするかに焦点を当てながら、探っていこう。

文書構造

Wordの読み取りと編集:IronWord (アイアンワード)を使用すると、編集や再利用のためにテキストを抽出したり、別の場所で使用する必要がある可能性のある画像を取得するなど、Word文書から特定の情報を引き出すことができます。 この機能は、Word文書をマージしたり、既存のDOCXファイルに含まれる情報を処理したりすることを目的としたアプリケーションには不可欠である。

複数のフォーマット:IronWord (アイアンワード)は幅広いファイル形式をサポートし、.NETアプリケーション内でWord文書を変換する際の実用性を高めています。

**ページ設定の編集IronWord (アイアンワード)を使えば、Word文書の物理的なレイアウトを簡単に調整できます。 さまざまなMS Wordファイルの用紙サイズを標準サイズまたはカスタムサイズに調整したり、文書のセクションごとに向きを変えたり、適切な配置を確保するために余白を設定したり、美的目的のために背景色を変更したり、セクションを強調したりすることもできます。

段落の追加:IronWord (アイアンワード) では、段落の追加と削除が可能です。 **段落内にテキストが入るこれは、大きなテキストセクションの編集や書式設定に不可欠です。 さらに、画像や図形をテキストに直接挿入したり、デザイン仕様に合わせてスタイルを調整したり、洗練された外観のために整列を設定したりすることで、段落を強化することができます。 また、箇条書きや番号リストを追加する機能も、コンテンツをより効果的に整理するのに役立つ。

using IronWord;
using IronWord.Models;
// Load docx
WordDocument doc = new WordDocument();
// Create and add styled text to a paragraph
Paragraph paragraph = new Paragraph();
paragraph.AddTextRun(new TextRun("Exploring text styles within a document."));
paragraph.AddTextRun(new TextRun("An example in italic.", new TextStyle { IsItalic = true }));
paragraph.AddTextRun(new TextRun("An example in bold.", new TextStyle { IsBold = true }));
// Add paragraph and export docx
doc.AddParagraph(paragraph);
doc.SaveAs("newdocument.docx");
using IronWord;
using IronWord.Models;
// Load docx
WordDocument doc = new WordDocument();
// Create and add styled text to a paragraph
Paragraph paragraph = new Paragraph();
paragraph.AddTextRun(new TextRun("Exploring text styles within a document."));
paragraph.AddTextRun(new TextRun("An example in italic.", new TextStyle { IsItalic = true }));
paragraph.AddTextRun(new TextRun("An example in bold.", new TextStyle { IsBold = true }));
// Add paragraph and export docx
doc.AddParagraph(paragraph);
doc.SaveAs("newdocument.docx");
Imports IronWord
Imports IronWord.Models
' Load docx
Private doc As New WordDocument()
' Create and add styled text to a paragraph
Private paragraph As New Paragraph()
paragraph.AddTextRun(New TextRun("Exploring text styles within a document."))
paragraph.AddTextRun(New TextRun("An example in italic.", New TextStyle With {.IsItalic = True}))
paragraph.AddTextRun(New TextRun("An example in bold.", New TextStyle With {.IsBold = True}))
' Add paragraph and export docx
doc.AddParagraph(paragraph)
doc.SaveAs("newdocument.docx")
VB   C#

テーブルの追加テーブル はDOCXファイルの重要な構成要素であり、IronWordで簡単に操作でき、ダイナミックな文書生成をサポートします。 行や列を追加したり削除したりすることができる。これは、データ量が変化する可能性のあるダイナミック・ドキュメント生成では重要な操作である。 セルの結合と分割により、複雑な表の書式設定にも対応し、ボーダーやレイアウト寸法のカスタマイズにより、洗練されたプロフェッショナルな外観を実現します。

using IronWord;
using IronWord.Models;
// 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;
// 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
' Create a table cell with a paragraph containing text
Private cell As New TableCell(New Paragraph(New TextRun("Sample text")))
' Configure a common border style for the table
Private 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")
VB   C#

.NET Word API(開発者のための仕組み):図1 - 出力された表のあるPDF

ドキュメント要素

TextRunsの追加:この機能は、テキストの内容をきめ細かくコントロールするものです。 テキストランの追加、追加、分割ができるので、ダイナミックな文書作成には欠かせません。 フォントファミリー、サイズ、色の変更、太字、斜体、その他のテキスト装飾の追加など、スタイリングオプションは多岐にわたる。 また、テキストランの中に画像を埋め込むこともでき、リッチで視覚的に魅力的な文書を作成できます。

画像の追加:IronWord (アイアンワード)では、包括的なイメージの追加が可能です。 **画像操作 ワード文書内 さまざまなソースから画像を読み込み、シームレスにテキストを回り込ませ、レイアウトに合わせてサイズを調整できます。 位置のオフセットとドキュメントのコーナーからの距離を設定できるので、画像は常に完璧に配置されます。

using IronWord;
using IronWord.Models;
WordDocument doc = new WordDocument();
IronWord.Models.Image image = new IronWord.Models.Image("your-image.jpg")
{
    Width = 200, // In unit pixel
    Height = 200 // In unit pixel
};
Create paragraph, add image, add paragraph to doc, and export
Paragraph paragraph = new Paragraph();
paragraph.AddImage(image);
doc.AddParagraph(paragraph);
doc.SaveAs("save_document.docx");
using IronWord;
using IronWord.Models;
WordDocument doc = new WordDocument();
IronWord.Models.Image image = new IronWord.Models.Image("your-image.jpg")
{
    Width = 200, // In unit pixel
    Height = 200 // In unit pixel
};
Create paragraph, add image, add paragraph to doc, and export
Paragraph paragraph = new Paragraph();
paragraph.AddImage(image);
doc.AddParagraph(paragraph);
doc.SaveAs("save_document.docx");
Imports IronWord
Imports IronWord.Models
Private doc As New WordDocument()
Private image As New IronWord.Models.Image("your-image.jpg") With {
	.Width = 200,
	.Height = 200
}
Private paragraph, add, add, [and] As Create
paragraph.AddImage(image)
doc.AddParagraph(paragraph)
doc.SaveAs("save_document.docx")
VB   C#

図形の追加:アイアンワードでは、正確な挿入とカスタマイズが可能です。 シェイプタイプを設定できます。 (長方形、円、矢印など。)また、テキストがどのようにシェイプを囲むかを決定したり、正確な寸法と位置を指定したり、シェイプを回転させて希望の視覚効果を得ることもできます。

互換性

.NET バージョンとプロジェクトの種類

.NET Word API (開発者のための仕組み):図2 - IronWordが対応する.NETバージョンとプロジェクトタイプ (.NET用アイアンワード)

IronWordは.NETエコシステム内で幅広い互換性を持つように設計されており、.NETコア、.NETスタンダード、.NETフレームワークなど、さまざまな.NETバージョンでC#、VB.NET、F#をサポートしています。 これにより、現代的なアプリケーションでもレガシー・アプリケーションでも、その有用性が保証される。 Blazor、WebForms、Xamarin、MAUI、WPF、コンソール・アプリケーションとの統合により、Web、モバイル、デスクトップ・アプリケーションに対応します。

アプリ環境

.NET Word API (開発者のための仕組み):図3 - アイアンワードが動作するアプリ環境

アプリケーション環境に関しては、IronWordはWindows、Linux、iOS、Androidの各プラットフォームに対応し、Docker、Azure、AWSでのコンテナ化やクラウド展開もサポートしている。 この幅広いサポートにより、さまざまな環境での開発が容易になる。

OSとIDE

.NET Word API (開発者のための仕組み):図4 - OSとIDE'のIronWord (アイアンワード)の互換性

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

ライセンス・オプション

.NET Word API (開発者向けの仕組み):図5 - アイアンワードライセンスページ

アイアンワードは、さまざまな開発者や組織のニーズに対応するために、さまざまなライセンスオプションを提供しています。 永久ライセンスを提供しているため、支払いは一度だけで、継続費用はかからない。 すべてのライセンスには、1年間の製品サポートとアップデートが含まれています。 ライセンシングの段階は、開発者の数、場所、プロジェクトの数に基づいて設計されています。 以下の内容を日本語に翻訳してください:

あなたも取得できます 無料体験 ライセンスを購入する前に、実際に体験することができます。

ライトライセンス

このオプションは、プロジェクトに単独で取り組む個人開発者向けに調整されている。 価格は $599 で、1つの場所で1人の開発者をカバーします。

プラスライセンス

小規模チームを対象としたこのライセンスは1,499ドルで、最大3人の開発者を収容し、3つのプロジェクトで3つの場所で使用できる。

プロフェッショナルライセンス

大規模チーム向けのプロフェッショナル・ライセンスは2,999ドルで、最大10人の開発者をサポートする。 より大規模な業務に対応するように設計されており、プレミアムサポート機能が含まれている。

結論

最後に IronWord (アイアンワード) は、堅牢で柔軟な.NET Word APIとして登場し、個々の開発者やチームの多様なニーズに対応するさまざまなライセンスオプションを提供する。 その機能は、Word文書の効率的な管理と操作を可能にし、複数の.NETバージョンとプロジェクトタイプにまたがる互換性を保証します。

< 以前
C#でドキュメントをWordにエクスポートする方法
次へ >
C# で Word 自動化を実行する方法

準備はできましたか? バージョン: 2024.9 新発売

無料のNuGetダウンロード 総ダウンロード数: 4,489 View Licenses >