删除字段
Contents
[
Hide
]
有时需要从文档中删除某个字段。当要替换为不同的字段类型或文档中不再需要该字段时,可能会发生这种情况。例如保存为 HTML 时的 TOC
字段。
要删除使用 DocumentBuilder.insert_field 插入到文档中的字段,请使用返回的 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-Python-via-.NET | |
doc = aw.Document(docs_base.my_dir + "Various fields.docx") | |
field = doc.range.fields[0] | |
field.remove() |
您可以从 Aspose.Words GitHub 下载本示例的示例文件。