首先,请查看结果word文档的有效截图:

步骤如下:
第 1 步:创建一个新文档并在文档中添加一个部分。
Document document = new Document();Section section=document.AddSection();
第 2 步:通过附加 HTML 将单词列表添加到段落中。
Paragraph paragraph = section.AddParagraph();paragraph.AppendHTML("<ol><li>Version 1</li><li>Version 2</li><li>Version 3</li></ol>");
第 3 步:设置段落的项目符 样式。
foreach (Paragraph p in section.Paragraphs){p.ApplyStyle(BuiltinStyle.Heading2);p.ListFormat.CurrentListLevel.NumberPosition = 20;p.ListFormat.CurrentListLevel.TextPosition = 30;}
第 4 步:将文档保存到文件
document.SaveToFile("result.docx",FileFormat.Docx);
完整代码:
using Spire.Doc;using Spire.Doc.Documents;namespace SetWordBullet{class Program{static void Main(string[] args){Document document = new Document();Section section = document.AddSection();Paragraph paragraph = section.AddParagraph();paragraph.AppendHTML("<ol><li>Version 1</li><li>Version 2</li><li>Version 3</li></ol>");foreach (Paragraph p in section.Paragraphs){p.ApplyStyle(BuiltinStyle.Heading2);p.ListFormat.CurrentListLevel.NumberPosition = 20;p.ListFormat.CurrentListLevel.TextPosition = 30;}document.SaveToFile("result.docx", FileFormat.Docx);}}}
欢迎下载|体验更多E-iceblue产品
如需获取更多产品相关信息请咨询在线客服
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!