Word控件Spire.Doc 【段落处理】教程(十九):在 C#/VB.NET 中将 ASCII 字符设置为 Word 中的项目符号
2023-09-11 14:14:49 时间
本文向您展示了如何使用 Spire.Doc 与 C# 和 VB.NET 将 ASCII 字符(特殊符号)设置为 Word 文档中的项目符号。
Spire.Doc for.NET 最新下载(qun;767755948)https://www.evget.com/product/3368/download
[C#]
using Spire.Doc; using Spire.Doc.Documents; namespace SetBulletCharacter { class Program { static void Main(string[] args) { //Create a Document object and add a section Document doc = new Document(); Section section = doc.AddSection(); //Create four list styles based on different ASCII characters ListStyle listStyle1 = new ListStyle(doc, ListType.Bulleted); listStyle1.Name = "liststyle"; listStyle1.Levels[0].BulletCharacter = "\x006e"; listStyle1.Levels[0].CharacterFormat.FontName = "Wingdings"; doc.ListStyles.Add(listStyle1); ListStyle listStyle2 = new ListStyle(doc, ListType.Bulleted); listStyle2.Name = "liststyle2"; listStyle2.Levels[0].BulletCharacter = "\x0075"; listStyle2.Levels[0].CharacterFormat.FontName = "Wingdings"; doc.ListStyles.Add(listStyle2); ListStyle listStyle3 = new ListStyle(doc, ListType.Bulleted); listStyle3.Name = "liststyle3"; listStyle3.Levels[0].BulletCharacter = "\x00b2"; listStyle3.Levels[0].CharacterFormat.FontName = "Wingdings"; doc.ListStyles.Add(listStyle3); ListStyle listStyle4 = new ListStyle(doc, ListType.Bulleted); listStyle4.Name = "liststyle4"; listStyle4.Levels[0].BulletCharacter = "\x00d8"; listStyle4.Levels[0].CharacterFormat.FontName = "Wingdings"; doc.ListStyles.Add(listStyle4); //Add four paragraphs and apply list style separately Paragraph p1 = section.Body.AddParagraph(); p1.AppendText("Spire.Doc for .NET"); p1.ListFormat.ApplyStyle(listStyle1.Name); Paragraph p2 = section.Body.AddParagraph(); p2.AppendText("Spire.PDF for .NET"); p2.ListFormat.ApplyStyle(listStyle2.Name); Paragraph p3 = section.Body.AddParagraph(); p3.AppendText("Spire.XLS for .NET"); p3.ListFormat.ApplyStyle(listStyle3.Name); Paragraph p4 = section.Body.AddParagraph(); p4.AppendText("Spire.Presentation for .NET"); p4.ListFormat.ApplyStyle(listStyle4.Name); //Save to file doc.SaveToFile("output.docx", FileFormat.Docx2013); } } }
[VB.NET]
Imports Spire.Doc Imports Spire.Doc.Documents Namespace SetBulletCharacter Class Program Shared Sub Main(ByVal args() As String) 'Create a Document object and add a section Document doc = New Document() Dim section As Section = doc.AddSection() 'Create four list styles based on different ASCII characters Dim listStyle1 As ListStyle = New ListStyle(doc, ListType.Bulleted) listStyle1.Name = "liststyle" listStyle1.Levels(0).BulletCharacter = "\x006e" listStyle1.Levels(0).CharacterFormat.FontName = "Wingdings" doc.ListStyles.Add(listStyle1) Dim listStyle2 As ListStyle = New ListStyle(doc, ListType.Bulleted) listStyle2.Name = "liststyle2" listStyle2.Levels(0).BulletCharacter = "\x0075" listStyle2.Levels(0).CharacterFormat.FontName = "Wingdings" doc.ListStyles.Add(listStyle2) Dim listStyle3 As ListStyle = New ListStyle(doc, ListType.Bulleted) listStyle3.Name = "liststyle3" listStyle3.Levels(0).BulletCharacter = "\x00b2" listStyle3.Levels(0).CharacterFormat.FontName = "Wingdings" doc.ListStyles.Add(listStyle3) Dim listStyle4 As ListStyle = New ListStyle(doc, ListType.Bulleted) listStyle4.Name = "liststyle4" listStyle4.Levels(0).BulletCharacter = "\x00d8" listStyle4.Levels(0).CharacterFormat.FontName = "Wingdings" doc.ListStyles.Add(listStyle4) 'Add four paragraphs and apply list style separately Dim p1 As Paragraph = section.Body.AddParagraph() p1.AppendText("Spire.Doc for .NET") p1.ListFormat.ApplyStyle(listStyle1.Name) Dim p2 As Paragraph = section.Body.AddParagraph() p2.AppendText("Spire.PDF for .NET") p2.ListFormat.ApplyStyle(listStyle2.Name) Dim p3 As Paragraph = section.Body.AddParagraph() p3.AppendText("Spire.XLS for .NET") p3.ListFormat.ApplyStyle(listStyle3.Name) Dim p4 As Paragraph = section.Body.AddParagraph() p4.AppendText("Spire.Presentation for .NET") p4.ListFormat.ApplyStyle(listStyle4.Name) 'Save to file doc.SaveToFile("output.docx", FileFormat.Docx2013) End Sub End Class End Namespace
相关文章
- 国内第一部C#.Net调用Matlab混合编程视频教程
- C# Asp.Net 判断字符串中是否包含指定字符或字符串(Contains/IndexOf)
- C#中HttpWebRequest的GetRequestStream执行的效率太低,甚至偶尔死掉
- C#.Net实体代码生成工具(EntitysCodeGenerate)的使用及.NET中的ORM实现
- C# 自定义光标 WaitCursor
- C#.NET常见问题(FAQ)-如何判断某个字符是否为汉字
- C#.NET常见问题(FAQ)-控制台程序如何输出Messagebox
- C#.NET如何将cs文件编译成dll文件 exe文件 如何调用dll文件
- C# winform 学习(一)
- .NET (C#) Internals: Delegates (2)
- C# 获取打印机列表以及串口
- .Net(c#)加密解密工具类:
- Asp.net(C#) windows 服务{用于实现计划任务,事件监控等}
- 重新整理数据结构与算法(c#)—— 线索化二叉树[二十]
- C# 设计时动态改变实体在PropertyGrid中显示出来的属性
- [转] C# 泛型类型参数的约束
- .NET平台开源项目速览(16)C#写PDF文件类库PDF File Writer介绍
- 【5.1送礼】国内第一部Matlab和C#.Net混合编程视频教程【免费】
- Atitit.java相比c#.net的优点 优缺点 v2 q330
- C#托付之愚见
- (三十八)c#Winform自定义控件-圆形进度条-HZHControls
- (7)C#的this关键字的三种用法
- 【转】 C#中检查网络是否连通的二种方法
- 从0开始搭建一个IoC容器(C#版)
- C# 基础小知识之yield 关键字
- C#习题二
- C#三角形面积求解