テキストを編集
IronWord を使って既存のWord文書内のテキストを編集するには、文書ツリー内のテキストを探し、その内容を変更します。 上のコード例では、最初の段落にあるTextRunにアクセスしています。 そして、TextRunのコンテンツを "This is the edited text "に変更します。このアクションはテキストの内容だけを変更し、TextRunに関連するスタイルは変更しません。
using IronWord; // Open existing Word WordDocument doc = new WordDocument("sample.docx"); // Edit existing text doc.Paragraphs[0].Texts[0].Text = "This is the edited text."; // Export docx doc.SaveAs("document.docx");
Imports IronWord ' Open existing Word Private doc As New WordDocument("sample.docx") ' Edit existing text Private doc.Paragraphs(0).Texts(0).Text = "This is the edited text." ' Export docx doc.SaveAs("document.docx")
Install-Package IronWord
IronWord を使って既存のWord文書内のテキストを編集するには、文書ツリー内のテキストを探し、その内容を変更します。 上のコード例では、最初の段落にあるTextRunにアクセスしています。 そして、TextRunのコンテンツを "This is the edited text "に変更します。このアクションはテキストの内容だけを変更し、TextRunに関連するスタイルは変更しません。
10 の .NET API 製品 オフィス文書用