フィールドの削除
Contents
[
Hide
]
場合によっては、ドキュメントからフィールドを削除することが必要になることがあります。これは、別のフィールド タイプに置き換える必要がある場合、またはフィールドがドキュメント内で不要になった場合に発生することがあります。たとえば、HTML に保存する場合の TOC
フィールドです。
DocumentBuilder.InsertField を使用してドキュメントに挿入されたフィールドを削除するには、返された Field オブジェクトを使用します。これは、ドキュメントからフィールドを簡単に削除するための便利な Remove メソッドを提供します。
次のコード例は、ドキュメントからフィールドを削除する方法を示しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(MyDir + "Various fields.docx"); | |
Field field = doc.Range.Fields[0]; | |
field.Remove(); |
この例のサンプル ファイルは Aspose.Words GitHub からダウンロードできます。