移除欄位
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 下載此範例的樣本檔案。