フィールドの削除
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-Java | |
Document doc = new Document(getMyDir() + "Various fields.docx"); | |
Field field = doc.getRange().getFields().get(0); | |
field.remove(); |
この例のサンプルファイルは、次の場所からダウンロードできます Aspose.Words GitHub.