逐次編集処理

Word APIの逐次編集処理では、Microsoft Wordで作成されたファイルについて以下の編集を行うことができます。
本機能は.NETインターフェイスでのみ有効です。

API仕様は、Doxygenによるドキュメントを参照してください。

段落の取得と追加

Word APIでは、以下の図の領域の段落の取得と追加ができます。
本文領域で取得または追加した段落については、脚注・文末脚注・コメントを追加することができます。
Document editable areas

以下に、Word APIを使用して、白紙のMicrosoft Wordファイルから上図と同じファイルを作成するサンプルコードを記載しています。

var inputFilePath = @""; var outputFilePath = @""; using var ahWord = new AHWordprocessingDocument(inputFilePath); var ahDocument = ahWord.AHDocument; var ahParagraph = ahDocument.GetParagraph(1); ahParagraph.AppendText("脚注"); var ahFootnote = ahParagraph.AddFootnote("Footnote"); ahParagraph = ahDocument.AddParagraph(); ahParagraph.AppendText("コメント"); var ahComment = ahParagraph.AddComment("Comment", "佐々木 京平", "コメント"); ahParagraph = ahDocument.InsertParagraph(2); ahParagraph.AppendText("文末脚注"); var ahEndnote = ahParagraph.AddEndnote("Endnote"); var ahSection = ahDocument.GetAHSection(1); var ahHeader = ahSection.AddHeader(AHHeaderFooterType.OddPages); ahParagraph = ahHeader.AddParagraph(); ahParagraph.AppendText("ヘッダー"); var ahFooter = ahSection.AddFooter(AHHeaderFooterType.OddPages); ahParagraph = ahFooter.AddParagraph(); ahParagraph.AppendText("フッター"); ahWord.Save(outputFilePath);
Document Manipulation Result

プロパティ情報の編集

Word APIでは、Microsoft Wordファイルのプロパティ情報の編集ができます。
以下に、白紙のMicrosoft Wordファイルにプロパティ情報を追加するサンプルコードと、 その結果のイメージを記載しています。

var inputFilePath = @""; var outputFilePath = @""; using var ahWord = new AHWordprocessingDocument(inputFilePath); var ahCore = ahWord.AHCore; ahCore.SetCreators("萩原", "久保"); ahCore.SetTitle("V0.5追加機能"); ahCore.SetDescription("プロパティ情報の追加"); ahCore.SetLastModifiedBy("佐々木"); ahCore.SetKeyWords("core", "app", "プロパティ"); var ahApp = ahWord.AHApp; ahApp.SetCompany("アンテナハウス"); ahApp.SetManagers("中原"); ahWord.Save(outputFilePath);
Document Manipulation Add Property Informations