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

C#とIronWordを使用してWord文書に記入可能なフォーム・テンプレートを作成する方法

プレースホルダー テキスト フィールドを含むテーブルベースのレイアウトを構築することにより、 IronWordライブラリを使用して C# で入力可能な Word フォーム テンプレートを作成します。 その後、実際のデータをプログラムで入力し、オプションで PDF 形式に変換できます。

構造化されたフォームによる情報収集は、求人応募を処理する人事部門から患者情報を収集する医療提供者まで、あらゆる業界のデータ収集に不可欠です。 入力可能なフォーム テンプレートをプログラムで構築すると、時間が節約され、.NET アプリケーション内の Word 文書間の一貫性が確保されます。 このチュートリアルでは、C#とIronWord(Microsoft Officeに依存せずにDOCXファイルを生成・編集するための.NET Wordライブラリ)を使用して、Word文書に記入可能なフォームテンプレートを作成する方法を示します。 最後に、データ入力用の完全な求人応募フォーム テンプレートが完成し、Word 文書を PDF 形式に変換して配布することもできます。

Word文書で記入可能なフォーム テンプレートとは

記入可能なフォームテンプレートは、ユーザーがテキストやその他のデータを入力できるように指定された領域で設計された構造化されたWord文書です。 これらのテンプレートは、テーブルとプレースホルダー テキスト フィールドを使用して整理されたレイアウトを作成し、プログラムで、または対話型フォームを通じて手動で実際のデータを入力することができます。 .NET アプリケーションを使用する場合、 IronWordなどのライブラリを、PowerPoint 管理用の IronPPTなどの他の Iron Software 製品と併用して、完全なドキュメント自動化ソリューションを作成できます。

Microsoft Wordは、プレーンテキストコンテンツコントロール、リッチテキストコンテンツコントロール、チェックボックスコンテンツコントロール、ドロップダウンリストコンテンツコントロール、コンボボックスコンテンツコントロール、日付ピッカーコンテンツコントロール、画像コンテンツコントロールなど、インタラクティブフィールド用のさまざまなコンテンツコントロールをサポートしています。 ネイティブ フォーム フィールドはインタラクティブなフォームを作成しますが、プレースホルダー テキストを使用するテンプレート ベースのアプローチでは、Web アプリケーションおよびサーバー環境でのドキュメント生成の柔軟性が向上します。 この柔軟性は、プレゼンテーション自動化でスライドを追加したりテキストを追加したりするのと同様に、複雑なドキュメント構造の管理にも拡張されます。

一般的な用途は以下のとおりです:

  • 記入欄のある求人申込書や入社フォーム
  • データ収集のための顧客登録とフィードバック調査
  • テキストボックスとチェックボックスのコントロールを備えた医療情報入力フォームと同意書 -ライセンスキー管理を必要とする可変テキストフィールドを含む契約テンプレート
  • PDF文書にエクスポートできる注文書と請求書

これらのフォームは構造化されているため、自動処理に最適です。 プレゼンテーションで画像を管理できるのと同様に、フォーム テンプレートではテキスト フィールドとともに視覚要素を組み込むことができます。 Word フォームを作成する場合でも、ツールを使用して空のプレゼンテーションを作成するプレゼンテーション ファイルを操作する場合でも、ドキュメント構造の同じ原則が適用されます。

C#で記入可能なフォーム テンプレートを作成するには?

フォーム テンプレートの作成に IronWord を使用する理由

まず、Visual Studio で新しい .NET コンソール アプリケーションを作成し、 IronWord NuGet パッケージをインストールします。 インストール プロセスは簡単で、他の Iron Software 製品のセットアップと同様です。 展開する前に、ライセンス要件を理解し、プロジェクトの範囲が拡大した場合のライセンス拡張のオプションを検討してください。

dotnet new console -n WordFormTemplate
cd WordFormTemplate
dotnet add package IronWord
dotnet new console -n WordFormTemplate
cd WordFormTemplate
dotnet add package IronWord
SHELL

あるいは、Visual StudioのNuGetパッケージ・マネージャーから "IronWord "を検索してインストールしてください。この.NET Wordライブラリは、Microsoft OfficeやWord Interopがシステムにインストールされていなくても動作します。 複数のドキュメント タイプを管理するチームの場合は、 IronPPT の変更ログを調べて、プレゼンテーション自動化が Word ドキュメント処理をどのように補完するかを確認することを検討してください。 将来のアップグレードを計画するときは、ドキュメント自動化スタック全体を評価します。

! Visual Studio の NuGet パッケージ マネージャー ウィンドウに IronWord パッケージの検索結果とインストール インターフェイスが表示されています

テーブルとプレースホルダーを使用してフォームを構造化するにはどうすればよいですか?

テーブルは、テーブル セルを適切に配置した、整理されたフォーム レイアウトの基盤となります。 ドキュメント オブジェクトは、Word 文書にテーブルやフォーム フィールドを追加するために使用されます。 プレゼンテーションでスライドを管理する方法と同様に、Word 文書では慎重な構造計画が必要です。 次のコード例は、ラベルと入力プレースホルダーを使用して基本的なフォーム構造を作成する方法を示しています。

using IronWord;
using IronWord.Models;

// Apply your license key
License.LicenseKey = "YOUR-LICENSE-KEY";

// Create a new document instance
WordDocument doc = new WordDocument();

// Create the form header
Paragraph header = new Paragraph();
var headerText = new IronWord.Models.TextContent("Job Application Form")
{
    Style = new TextStyle
    {
        TextFont = new Font() { FontFamily = "Arial", FontSize = 24 },
        IsBold = true,
        Color = new Color("#1a1a1a")
    }
};
header.AddText(headerText);
doc.AddParagraph(header);

// Add spacing paragraph
doc.AddParagraph(new Paragraph());

// Create a table for personal information section
Table personalInfoTable = new Table(4, 2);

// Set column labels and placeholder text fields
personalInfoTable.Rows[0].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Full Name:")));
personalInfoTable.Rows[0].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{FullName}")));

personalInfoTable.Rows[1].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Email Address:")));
personalInfoTable.Rows[1].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{Email}")));

personalInfoTable.Rows[2].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Phone Number:")));
personalInfoTable.Rows[2].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{Phone}")));

personalInfoTable.Rows[3].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Date of Application:")));
personalInfoTable.Rows[3].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{ApplicationDate}")));

doc.AddTable(personalInfoTable);

// Save the template to a file with descriptive name
doc.SaveAs("JobApplicationTemplate.docx");
Console.WriteLine("Form template created successfully!");
using IronWord;
using IronWord.Models;

// Apply your license key
License.LicenseKey = "YOUR-LICENSE-KEY";

// Create a new document instance
WordDocument doc = new WordDocument();

// Create the form header
Paragraph header = new Paragraph();
var headerText = new IronWord.Models.TextContent("Job Application Form")
{
    Style = new TextStyle
    {
        TextFont = new Font() { FontFamily = "Arial", FontSize = 24 },
        IsBold = true,
        Color = new Color("#1a1a1a")
    }
};
header.AddText(headerText);
doc.AddParagraph(header);

// Add spacing paragraph
doc.AddParagraph(new Paragraph());

// Create a table for personal information section
Table personalInfoTable = new Table(4, 2);

// Set column labels and placeholder text fields
personalInfoTable.Rows[0].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Full Name:")));
personalInfoTable.Rows[0].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{FullName}")));

personalInfoTable.Rows[1].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Email Address:")));
personalInfoTable.Rows[1].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{Email}")));

personalInfoTable.Rows[2].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Phone Number:")));
personalInfoTable.Rows[2].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{Phone}")));

personalInfoTable.Rows[3].Cells[0].AddParagraph(new Paragraph(new IronWord.Models.TextContent("Date of Application:")));
personalInfoTable.Rows[3].Cells[1].AddParagraph(new Paragraph(new IronWord.Models.TextContent("{ApplicationDate}")));

doc.AddTable(personalInfoTable);

// Save the template to a file with descriptive name
doc.SaveAs("JobApplicationTemplate.docx");
Console.WriteLine("Form template created successfully!");
Imports IronWord
Imports IronWord.Models

' Apply your license key
License.LicenseKey = "YOUR-LICENSE-KEY"

' Create a new document instance
Dim doc As New WordDocument()

' Create the form header
Dim header As New Paragraph()
Dim headerText = New IronWord.Models.TextContent("Job Application Form") With {
    .Style = New TextStyle With {
        .TextFont = New Font() With {.FontFamily = "Arial", .FontSize = 24},
        .IsBold = True,
        .Color = New Color("#1a1a1a")
    }
}
header.AddText(headerText)
doc.AddParagraph(header)

' Add spacing paragraph
doc.AddParagraph(New Paragraph())

' Create a table for personal information section
Dim personalInfoTable As New Table(4, 2)

' Set column labels and placeholder text fields
personalInfoTable.Rows(0).Cells(0).AddParagraph(New Paragraph(New IronWord.Models.TextContent("Full Name:")))
personalInfoTable.Rows(0).Cells(1).AddParagraph(New Paragraph(New IronWord.Models.TextContent("{FullName}")))

personalInfoTable.Rows(1).Cells(0).AddParagraph(New Paragraph(New IronWord.Models.TextContent("Email Address:")))
personalInfoTable.Rows(1).Cells(1).AddParagraph(New Paragraph(New IronWord.Models.TextContent("{Email}")))

personalInfoTable.Rows(2).Cells(0).AddParagraph(New Paragraph(New IronWord.Models.TextContent("Phone Number:")))
personalInfoTable.Rows(2).Cells(1).AddParagraph(New Paragraph(New IronWord.Models.TextContent("{Phone}")))

personalInfoTable.Rows(3).Cells(0).AddParagraph(New Paragraph(New IronWord.Models.TextContent("Date of Application:")))
personalInfoTable.Rows(3).Cells(1).AddParagraph(New Paragraph(New IronWord.Models.TextContent("{ApplicationDate}")))

doc.AddTable(personalInfoTable)

' Save the template to a file with descriptive name
doc.SaveAs("JobApplicationTemplate.docx")
Console.WriteLine("Form template created successfully!")
$vbLabelText   $csharpLabel

このコードは、 WordDocumentクラスを使用して新しいドキュメント インスタンスを作成し、Table クラスを使用して構造化されたフォームを構築します。 各行には、最初のセルにラベル、2番目のセルにプレースホルダ(中括弧で囲む)が含まれています。 TextContentクラスはプレーンテキストコンテンツを処理し、 TextStyleは書式設定を適用します。 プレースホルダー構文 { FieldName } は、後でテキストを実際のデータに置き換える領域をマークします。 このアプローチは、高度な書式設定オプションにIronWord ドキュメントを使用する場合と同様の柔軟性を提供します。

個人情報、職位の詳細、学歴の欄がプレースホルダテキストで埋められた、記入済みの雇用申込書を示す Microsoft Word 文書

! Microsoft Visual Studio デバッグ コンソールに緑色のテキストで"フォーム テンプレートが正常に作成されました"というメッセージが表示されています

複数セクションのフォームのベストプラクティスは何ですか?

次のコード例は、複数のセクションを含む完全な求人応募フォームを作成する方法を示しています。 従来の構造を好む開発者は、クラス宣言を使用してこれを名前空間にラップできます。 複雑なフォームを扱う場合は、コンテンツを階層的に整理するためのヒントを得るために、IronPPT のスライド管理テクニックを確認することを検討してください。

using IronWord;
using IronWord.Models;

License.LicenseKey = "YOUR-LICENSE-KEY";

// Create an empty document to start fresh
WordDocument doc = new WordDocument();

// Document title with rich text styling
Paragraph title = new Paragraph();
TextContent titleText = new TextContent("Employment Application Form");
titleText.Style = new TextStyle()
{
    TextFont = new Font() { FontFamily = "Arial", FontSize = 28 },
    IsBold = true
};
// Center the paragraph instead of using TextAlignment on TextStyle
title.Alignment = IronWord.Models.Enums.TextAlignment.Center;
title.AddText(titleText);
doc.AddParagraph(title);
doc.AddParagraph(new Paragraph());

// Section 1: Personal Information with text box style fields
AddSectionHeader(doc, "Personal Information");

Table personalTable = new Table(5, 2);
SetFormRow(personalTable, 0, "Full Name:", "{FullName}");
SetFormRow(personalTable, 1, "Email:", "{Email}");
SetFormRow(personalTable, 2, "Phone:", "{Phone}");
SetFormRow(personalTable, 3, "Address:", "{Address}");
SetFormRow(personalTable, 4, "Date of Birth:", "{DOB}");
doc.AddTable(personalTable);
doc.AddParagraph(new Paragraph());

// Section 2: Position Details - similar to combo box or drop down list selection
AddSectionHeader(doc, "Position Details");

Table positionTable = new Table(3, 2);
SetFormRow(positionTable, 0, "Position Applied For:", "{Position}");
SetFormRow(positionTable, 1, "Available Start Date:", "{StartDate}");
SetFormRow(positionTable, 2, "Desired Salary:", "{Salary}");
doc.AddTable(positionTable);
doc.AddParagraph(new Paragraph());

// Section 3: Education Background
AddSectionHeader(doc, "Education Background");

Table educationTable = new Table(3, 2);
SetFormRow(educationTable, 0, "Highest Degree:", "{Degree}");
SetFormRow(educationTable, 1, "Institution:", "{Institution}");
SetFormRow(educationTable, 2, "Graduation Year:", "{GradYear}");
doc.AddTable(educationTable);
doc.AddParagraph(new Paragraph());

// Section 4: Declaration - certification statement
Paragraph declaration = new Paragraph();
declaration.AddText(new TextContent("I certify that the information provided is accurate and complete."));
doc.AddParagraph(declaration);
doc.AddParagraph(new Paragraph());

Table signatureTable = new Table(1, 2);
SetFormRow(signatureTable, 0, "Signature:", "{Signature}");
doc.AddTable(signatureTable);

// Save template file
doc.SaveAs("CompleteJobApplication.docx");
Console.WriteLine("Complete job application form created!");

// Helper method to add styled section headers
void AddSectionHeader(WordDocument document, string headerText)
{
    Paragraph sectionHeader = new Paragraph();
    TextContent sectionText = new TextContent(headerText);
    sectionText.Style = new TextStyle()
    {
        TextFont = new Font() { FontFamily = "Arial", FontSize = 14 },
        IsBold = true,
        Color = new Color("#333333")
    };
    sectionHeader.AddText(sectionText);
    document.AddParagraph(sectionHeader);
}

// Helper method to populate table cells with label and placeholder
void SetFormRow(Table table, int rowIndex, string label, string placeholder)
{
    table.Rows[rowIndex].Cells[0].AddParagraph(new Paragraph(new TextContent(label)));
    table.Rows[rowIndex].Cells[1].AddParagraph(new Paragraph(new TextContent(placeholder)));
}
using IronWord;
using IronWord.Models;

License.LicenseKey = "YOUR-LICENSE-KEY";

// Create an empty document to start fresh
WordDocument doc = new WordDocument();

// Document title with rich text styling
Paragraph title = new Paragraph();
TextContent titleText = new TextContent("Employment Application Form");
titleText.Style = new TextStyle()
{
    TextFont = new Font() { FontFamily = "Arial", FontSize = 28 },
    IsBold = true
};
// Center the paragraph instead of using TextAlignment on TextStyle
title.Alignment = IronWord.Models.Enums.TextAlignment.Center;
title.AddText(titleText);
doc.AddParagraph(title);
doc.AddParagraph(new Paragraph());

// Section 1: Personal Information with text box style fields
AddSectionHeader(doc, "Personal Information");

Table personalTable = new Table(5, 2);
SetFormRow(personalTable, 0, "Full Name:", "{FullName}");
SetFormRow(personalTable, 1, "Email:", "{Email}");
SetFormRow(personalTable, 2, "Phone:", "{Phone}");
SetFormRow(personalTable, 3, "Address:", "{Address}");
SetFormRow(personalTable, 4, "Date of Birth:", "{DOB}");
doc.AddTable(personalTable);
doc.AddParagraph(new Paragraph());

// Section 2: Position Details - similar to combo box or drop down list selection
AddSectionHeader(doc, "Position Details");

Table positionTable = new Table(3, 2);
SetFormRow(positionTable, 0, "Position Applied For:", "{Position}");
SetFormRow(positionTable, 1, "Available Start Date:", "{StartDate}");
SetFormRow(positionTable, 2, "Desired Salary:", "{Salary}");
doc.AddTable(positionTable);
doc.AddParagraph(new Paragraph());

// Section 3: Education Background
AddSectionHeader(doc, "Education Background");

Table educationTable = new Table(3, 2);
SetFormRow(educationTable, 0, "Highest Degree:", "{Degree}");
SetFormRow(educationTable, 1, "Institution:", "{Institution}");
SetFormRow(educationTable, 2, "Graduation Year:", "{GradYear}");
doc.AddTable(educationTable);
doc.AddParagraph(new Paragraph());

// Section 4: Declaration - certification statement
Paragraph declaration = new Paragraph();
declaration.AddText(new TextContent("I certify that the information provided is accurate and complete."));
doc.AddParagraph(declaration);
doc.AddParagraph(new Paragraph());

Table signatureTable = new Table(1, 2);
SetFormRow(signatureTable, 0, "Signature:", "{Signature}");
doc.AddTable(signatureTable);

// Save template file
doc.SaveAs("CompleteJobApplication.docx");
Console.WriteLine("Complete job application form created!");

// Helper method to add styled section headers
void AddSectionHeader(WordDocument document, string headerText)
{
    Paragraph sectionHeader = new Paragraph();
    TextContent sectionText = new TextContent(headerText);
    sectionText.Style = new TextStyle()
    {
        TextFont = new Font() { FontFamily = "Arial", FontSize = 14 },
        IsBold = true,
        Color = new Color("#333333")
    };
    sectionHeader.AddText(sectionText);
    document.AddParagraph(sectionHeader);
}

// Helper method to populate table cells with label and placeholder
void SetFormRow(Table table, int rowIndex, string label, string placeholder)
{
    table.Rows[rowIndex].Cells[0].AddParagraph(new Paragraph(new TextContent(label)));
    table.Rows[rowIndex].Cells[1].AddParagraph(new Paragraph(new TextContent(placeholder)));
}
Imports IronWord
Imports IronWord.Models

License.LicenseKey = "YOUR-LICENSE-KEY"

' Create an empty document to start fresh
Dim doc As New WordDocument()

' Document title with rich text styling
Dim title As New Paragraph()
Dim titleText As New TextContent("Employment Application Form")
titleText.Style = New TextStyle() With {
    .TextFont = New Font() With {.FontFamily = "Arial", .FontSize = 28},
    .IsBold = True
}
' Center the paragraph instead of using TextAlignment on TextStyle
title.Alignment = IronWord.Models.Enums.TextAlignment.Center
title.AddText(titleText)
doc.AddParagraph(title)
doc.AddParagraph(New Paragraph())

' Section 1: Personal Information with text box style fields
AddSectionHeader(doc, "Personal Information")

Dim personalTable As New Table(5, 2)
SetFormRow(personalTable, 0, "Full Name:", "{FullName}")
SetFormRow(personalTable, 1, "Email:", "{Email}")
SetFormRow(personalTable, 2, "Phone:", "{Phone}")
SetFormRow(personalTable, 3, "Address:", "{Address}")
SetFormRow(personalTable, 4, "Date of Birth:", "{DOB}")
doc.AddTable(personalTable)
doc.AddParagraph(New Paragraph())

' Section 2: Position Details - similar to combo box or drop down list selection
AddSectionHeader(doc, "Position Details")

Dim positionTable As New Table(3, 2)
SetFormRow(positionTable, 0, "Position Applied For:", "{Position}")
SetFormRow(positionTable, 1, "Available Start Date:", "{StartDate}")
SetFormRow(positionTable, 2, "Desired Salary:", "{Salary}")
doc.AddTable(positionTable)
doc.AddParagraph(New Paragraph())

' Section 3: Education Background
AddSectionHeader(doc, "Education Background")

Dim educationTable As New Table(3, 2)
SetFormRow(educationTable, 0, "Highest Degree:", "{Degree}")
SetFormRow(educationTable, 1, "Institution:", "{Institution}")
SetFormRow(educationTable, 2, "Graduation Year:", "{GradYear}")
doc.AddTable(educationTable)
doc.AddParagraph(New Paragraph())

' Section 4: Declaration - certification statement
Dim declaration As New Paragraph()
declaration.AddText(New TextContent("I certify that the information provided is accurate and complete."))
doc.AddParagraph(declaration)
doc.AddParagraph(New Paragraph())

Dim signatureTable As New Table(1, 2)
SetFormRow(signatureTable, 0, "Signature:", "{Signature}")
doc.AddTable(signatureTable)

' Save template file
doc.SaveAs("CompleteJobApplication.docx")
Console.WriteLine("Complete job application form created!")

' Helper method to add styled section headers
Sub AddSectionHeader(ByVal document As WordDocument, ByVal headerText As String)
    Dim sectionHeader As New Paragraph()
    Dim sectionText As New TextContent(headerText)
    sectionText.Style = New TextStyle() With {
        .TextFont = New Font() With {.FontFamily = "Arial", .FontSize = 14},
        .IsBold = True,
        .Color = New Color("#333333")
    }
    sectionHeader.AddText(sectionText)
    document.AddParagraph(sectionHeader)
End Sub

' Helper method to populate table cells with label and placeholder
Sub SetFormRow(ByVal table As Table, ByVal rowIndex As Integer, ByVal label As String, ByVal placeholder As String)
    table.Rows(rowIndex).Cells(0).AddParagraph(New Paragraph(New TextContent(label)))
    table.Rows(rowIndex).Cells(1).AddParagraph(New Paragraph(New TextContent(placeholder)))
End Sub
$vbLabelText   $csharpLabel

このコードでは、論理的な部分に整理された複数のセクションからなるフォームテンプレートを作成します。 ヘルパー メソッドAddSectionHeaderおよびSetFormRow 、PowerPoint スライドにテキストを追加するときに使用されるパターンと同様のパターンに従って、コードの繰り返しを削減します。 Table コンストラクタは行と列のパラメータを受け入れ、Rows と Cells コレクションは個々のテーブル・セルへのアクセスを提供します。 各セクションには、スタイル付きのヘッダーと、記入可能なフィールドを持つ表が続きます。 このモジュール式のアプローチにより、要件の変更に応じて日付選択フィールド、ドロップダウン リスト オプション、チェック ボックス セクションを簡単に追加できます。 画像コントロールを使用して画像を埋め込み、日付コントロールを使用して日付選択フィールドを追加することもできます。 画像処理のベストプラクティスについては、 IronPPT の画像管理ガイドを参照してください。

! Microsoft Word 文書には、氏名、メールアドレス、電話番号、申請日を表形式で入力できる求人応募フォーム テンプレートが表示されています。

フォーム テンプレートにデータを入力するには?

テキスト置換方法とは何ですか?

テンプレートが存在すると、テキスト置換を使用して実際のデータを簡単に入力できます。 このアプローチは、プレースホルダーが動的な値に置き換えられるプレゼンテーション コンテンツの管理と概念的に似ています。 次のコード・スニペットは、サンプル応募者情報をフォームに入力するデモです:

using IronWord;

License.LicenseKey = "YOUR-LICENSE-KEY";

// Load the template document
WordDocument doc = new WordDocument("CompleteJobApplication.docx");

// Define replacement data - example using John Doe as applicant
var applicantData = new Dictionary<string, string>
{
    { "{FullName}", "John Doe" },
    { "{Email}", "john.doe@email.com" },
    { "{Phone}", "(555) 123-4567" },
    { "{Address}", "123 Main Street, Chicago, IL 60601" },
    { "{DOB}", "March 15, 1992" },
    { "{Position}", "Senior Software Developer" },
    { "{StartDate}", "January 15, 2025" },
    { "{Salary}", "$95,000" },
    { "{Degree}", "Bachelor of Science in Computer Science" },
    { "{Institution}", "University of Illinois" },
    { "{GradYear}", "2014" },
    { "{Signature}", "John Doe" }
};

// Replace all placeholders with actual values
foreach (var field in applicantData)
{
    doc.Texts.ForEach(text => text.Replace(field.Key, field.Value));
}

// Save the filled form to a new file
doc.SaveAs("JohnDoe_Application.docx");
Console.WriteLine("Application form filled successfully!");
using IronWord;

License.LicenseKey = "YOUR-LICENSE-KEY";

// Load the template document
WordDocument doc = new WordDocument("CompleteJobApplication.docx");

// Define replacement data - example using John Doe as applicant
var applicantData = new Dictionary<string, string>
{
    { "{FullName}", "John Doe" },
    { "{Email}", "john.doe@email.com" },
    { "{Phone}", "(555) 123-4567" },
    { "{Address}", "123 Main Street, Chicago, IL 60601" },
    { "{DOB}", "March 15, 1992" },
    { "{Position}", "Senior Software Developer" },
    { "{StartDate}", "January 15, 2025" },
    { "{Salary}", "$95,000" },
    { "{Degree}", "Bachelor of Science in Computer Science" },
    { "{Institution}", "University of Illinois" },
    { "{GradYear}", "2014" },
    { "{Signature}", "John Doe" }
};

// Replace all placeholders with actual values
foreach (var field in applicantData)
{
    doc.Texts.ForEach(text => text.Replace(field.Key, field.Value));
}

// Save the filled form to a new file
doc.SaveAs("JohnDoe_Application.docx");
Console.WriteLine("Application form filled successfully!");
Imports IronWord

License.LicenseKey = "YOUR-LICENSE-KEY"

' Load the template document
Dim doc As New WordDocument("CompleteJobApplication.docx")

' Define replacement data - example using John Doe as applicant
Dim applicantData As New Dictionary(Of String, String) From {
    {"{FullName}", "John Doe"},
    {"{Email}", "john.doe@email.com"},
    {"{Phone}", "(555) 123-4567"},
    {"{Address}", "123 Main Street, Chicago, IL 60601"},
    {"{DOB}", "March 15, 1992"},
    {"{Position}", "Senior Software Developer"},
    {"{StartDate}", "January 15, 2025"},
    {"{Salary}", "$95,000"},
    {"{Degree}", "Bachelor of Science in Computer Science"},
    {"{Institution}", "University of Illinois"},
    {"{GradYear}", "2014"},
    {"{Signature}", "John Doe"}
}

' Replace all placeholders with actual values
For Each field In applicantData
    doc.Texts.ForEach(Sub(text) text.Replace(field.Key, field.Value))
Next

' Save the filled form to a new file
doc.SaveAs("JohnDoe_Application.docx")
Console.WriteLine("Application form filled successfully!")
$vbLabelText   $csharpLabel

テキスト要素のReplaceメソッドは、プレースホルダートークンを実際の値に置き換えます。 辞書を使用すると、データが整理され、データベース、API、または Web アプリケーションのユーザー入力からフォームに簡単に入力できるようになります。 Texts プロパティはドキュメント内のすべてのテキスト コンテンツへのアクセスを提供し、 ForEach各テキスト要素を反復処理して置換を実行します。 このパターンは、単一のテンプレートから複数のパーソナライズされたドキュメントを生成するのに適しており、バッチ処理に最適です。 このような自動化を展開する前に、実稼働環境に適したライセンス キー構成を確認してください。

プレースホルダーフィールドに実際のデータが入力された、完成した雇用申請書を示す Microsoft Word 文書

記入済みのフォームを安全に保管するには?

フォームに入力した後、Word 文書に保護を適用して文書のセキュリティを強化できます。 これには、読み取り専用制限とパスワード要件による保護の設定が含まれ、許可されたユーザーのみがコンテンツを変更できるようにします。 プレゼンテーション管理システムでアクセス制御を実装する方法と同様に、機密データを扱う際にはセキュリティを考慮することが重要です。 保存中および転送中のデータの暗号化、フォーム アクセスの監査ログ、さまざまなユーザー タイプに対するロールベースの権限などの追加のセキュリティ レイヤーの実装を検討してください。

入力可能な Word フォームを PDF に変換するにはどうすればいいですか?

記入可能なWordフォームをPDFに変換することは、フォームを普遍的にアクセスしやすく、共有しやすくするために不可欠なステップです。 IronWordなどの .NET Word ライブラリを使用すると、フォーム フィールドを含む Word 文書を PDF 文書に効率的に変換できます。 このプロセスには、Word 文書の読み込み、フォーム フィールドへのアクセス、ライブラリの変換方法を使用したすべてのコンテンツを保持する PDF ファイルの生成が含まれます。 変換ワークフローは、ドキュメント構造を形式間で保持する必要がある空のプレゼンテーションを作成するときに使用される概念を反映しています。

完成したPDF文書では、記入可能なフォームフィールドが保持されるため、ユーザーは標準的なPDFビューアーを使用してフォームを完成させることができます。 これは、フォームを広く配布し、異なるプラットフォームやデバイス間での互換性を確保する必要がある組織にとって特に有用です。 .NET Word ライブラリの変換機能を使用すると、Word でプロフェッショナルなフォームを作成し、Word 文書を PDF にシームレスに変換して最終配布できるため、ワークフローが簡素化され、アクセシビリティが向上します。 複数のドキュメント タイプを必要とするエンタープライズ展開の場合は、完全なドキュメント処理のニーズをカバーするライセンス アップグレードを検討してください。

記入可能な PDF を配布するには?

記入可能なPDFを作成したら、それをユーザーに配布するのは簡単で、非常に柔軟です。 記入可能なPDFは、メールで共有したり、ウェブアプリケーションに埋め込んだり、DropboxやGoogle Driveなどのクラウドストレージサービスにアップロードしたりできます。これにより、ユーザーはPDFを簡単にダウンロードし、Adobe Acrobat ReaderなどのPDFビューアを使ってフォームに記入し、記入済みの文書を電子的に返送できます。 最新の配布戦略では、IronPPT が製品の更新を追跡するのと同様に、フォームのバージョンを追跡するドキュメント管理システムと統合されることがよくあります。

このデジタル配信プロセスは、データ収集を加速させるだけでなく、物理的なペーパーワークを不要にするため、リモートチームやオンラインワークフローに最適です。 求人応募、顧客からのフィードバック、登録の詳細などを収集する場合、入力可能な PDF を配布すると、組織と回答者の両方にとってスムーズで効率的なペーパーレスなエクスペリエンスが保証されます。 フォームが利用可能になったときに受信者に通知し、完了ステータスを追跡し、保留中の送信についてリマインダーを送信する自動ワークフローの実装を検討してください。 電子メール マーケティング プラットフォームとの統合により、マージ フィールドを通じてパーソナライズを維持しながら大量配信を簡素化できます。## どのような高度なフォーム機能を実装できますか?

入力可能なフォームをさらに改善するには、ロジックや検証などの高度な機能を追加することを検討してください。 Logic を使用すると、ユーザー入力に動的に応答するインタラクティブなフォームを作成できます。 たとえば、以前の回答に基づいてセクションを表示または非表示にしたり、特定の条件が満たされた場合にのみ特定のフィールドを有効にしたりできます。 バリデーションは、ユーザーが入力したデータが、正しい日付形式、必須項目、有効な電子メールアドレスなどの要件を満たしていることを確認します。 これらの機能は、プレゼンテーション ソフトウェアでスライドを管理するときに利用できる動的コンテンツ機能に似ています。

多くの.NET Wordライブラリは、コードによるこれらの高度な機能の作成をサポートしており、ユーザーを誘導し、エラーを減らす洗練されたフォームを構築することができます。 Word文書のテンプレートにロジックと検証を組み込むことで、データを収集するだけでなく、受信した情報の品質と一貫性を向上させるインタラクティブなフォームを作成できます。 高度な実装には次のようなものが含まれます。

  • 合計を自動的に計算したり数式を適用したりする計算フィールド
  • 必須フィールドまたはエラーを強調表示する条件付き書式
  • 動的なフィールドラベルと説明による多言語サポート
  • リアルタイム検証のための外部データソースとの統合
  • 正規表現またはビジネスロジックを使用したカスタム検証ルール
  • フォームの完了率を示す進捗インジケーター

複雑なフォームのシナリオでは、技術者以外のユーザーがコーディングなしでテンプレートを作成および変更できるようにするフォーム ビルダー インターフェイスの実装を検討してください。 このアプローチを適切なライセンス拡張と組み合わせることで、大規模な組織全体で柔軟なフォーム管理が可能になります。

次のステップは何ですか?

IronWordを使用して C# で入力可能なフォーム テンプレートを作成すると、.NET アプリケーションのドキュメント生成ワークフローが簡素化されます。 テーブルベースのレイアウトアプローチは、適切に整列されたテーブルセルを持つプロフェッショナルで構造化されたフォームを作成し、テンプレート置換パターンは、あらゆるソースからの効率的なデータ入力を可能にします。 ドキュメント自動化のニーズが拡大するにつれて、プレゼンテーション自動化用の IronPPTなどの補完ツールを検討し、完全なドキュメント処理ソリューションを構築することを検討してください。

無料トライアルを開始してIronWordの全機能をお試しいただくか、ライセンスを購入して本番環境に導入してください。 実装に関するご質問は、当社のエンジニアリングチームにチャットでお問い合わせください。 複雑なフォーム シナリオ、複数のドキュメントの処理、エンタープライズ規模の実装を示す詳細な API リファレンスと高度な例については、 IronWord のドキュメントを確認してください。

よくある質問

IronWordとは何か?

IronWordは.NET Wordライブラリで、開発者はMicrosoft Officeに依存することなくDOCXファイルを生成、編集することができます。

IronWordを使ってC#で入力可能なフォームを作成するにはどうすればいいですか?

IronWordを使ってC#で記入可能なフォームを作成するには、プログラムでフォーム・テンプレートを作成します。

記入可能なフォームテンプレートの作成が有益な理由

記入可能なフォームテンプレートの作成は、データ収集プロセスを合理化し、ドキュメントの一貫性を確保し、さまざまなアプリケーションや業界で時間を節約できるため、有益です。

記入可能なフォームテンプレートを使用すると、どのような業界でメリットがありますか?

人事、医療、構造化されたデータ収集が必要なあらゆる分野で、記入可能なフォームテンプレートを使用することで、申請書を処理し、重要な情報を効率的に収集することができます。

IronWordを使用するためにMicrosoft Officeをインストールする必要がありますか?

IronWordを使用するためにMicrosoft Officeをインストールする必要はありません。Microsoft Officeに依存することなく、DOCXファイルの生成と編集が可能です。

IronWordは大規模な文書処理に対応できますか?

IronWordは大規模な文書処理を効率的に処理するように設計されており、企業レベルのアプリケーションに適しています。

IronWordで使用されるプログラミング言語は何ですか?

IronWordはC#で使用されるため、.NETフレームワークで作業する開発者に最適です。

IronWordをプロジェクトに統合するためのサポートはありますか?

IronWordをプロジェクトにシームレスに統合するために、Iron Softwareは包括的なサポートとドキュメントを提供します。

IronWordはWord文書の作成と編集の両方に使用できますか?

IronWordは新しいWord文書の作成と既存の文書の編集の両方に使用できます。

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