添加段落 IronWord 中的"添加段落"功能允许开发人员将整个段落插入到现有的 Word 文档中,从而提供了一种有效构建和组织内容的方法。 通过添加段落,开发人员可以将格式不同的多段文本合并成一个连贯的文本块。 此功能对于构建需要将文本分组并设置样式的动态文档(例如报告、文章或信件)尤其有用。 它在文本呈现方式上提供了灵活性,允许在单个段落中包含各种格式选项,如粗体、斜体和其他样式。 添加段落的功能有助于保持文档结构的清晰性,并确保内容组织得当,便于阅读。 Adding Paragraphs in C The Paragraph class in IronWord represents a block of text that can contain both unstyled text and styled content. When working with paragraphs, developers can combine plain TextContent with styled Run objects to create rich, formatted text blocks. To add plain text directly to a paragraph, use the AddText method with a TextContent object. 这非常适合不需要特定格式的纯文本。 For styled content, create a Run object containing TextContent, then assign a TextStyle to the Run. The TextStyle can specify formatting such as bold, italic, font family, font size, and color. Once the Run is styled, use the AddChild method to add it to the paragraph. This method is specifically designed for adding Run objects with formatting. 一个段落可以包含多个不同样式的文本行,从而在统一的文本块内实现灵活的文本格式设置。 After constructing the paragraph with all desired content, use AddParagraph on the WordDocument to insert it into the document. 这种方法遵循文档层次结构:Word文档→文档节→段落→运行→文本内容,确保在保存文档时保留正确的结构和格式。 使用 IronWord 探索更多关于文档元素的信息 相关文档链接 在GitHub上查看 相关教程 相关操作指南 类文档 下载IronWord DLL 报告此页面的问题 准备开始了吗? Nuget 下载 36,204 | 版本: 2026.3 刚刚发布 免费试用 免费 NuGet 下载 总下载量:36,204 查看许可证 还在滚动吗? 想快速获得证据? PM > Install-Package IronWord 运行示例 观看您的数据变成 Word 文档。 免费 NuGet 下载 总下载量:36,204 查看许可证