在构建Word文档过程中记录对象树,提供开发者必要的调试见解和验证工具,使他们能够快速识别并纠正文档结构中的错误或不一致之处。 通过分析对象树,可以帮助开发人员识别和解决构建过程中的低效问题,从而有助于性能优化。 总而言之,记录对象树可以简化开发流程,确保高效创建高质量的 Word 文档。
通过 IronWord 教程探索文档元素。using IronWord;
using IronWord.Models;
using System.Linq;
WordDocument docx = new WordDocument("Table.docx");
// Log object tree of the whole document
docx.LogObjectTree();
// Log object tree of table 0
docx.Children.OfType<Table>().First().LogObjectTree();
Imports IronWord
Imports IronWord.Models
Imports System.Linq
Dim docx As New WordDocument("Table.docx")
' Log object tree of the whole document
docx.LogObjectTree()
' Log object tree of table 0
docx.Children.OfType(Of Table)().First().LogObjectTree()