viber

了解最新公司动态及行业资讯

当前位置:首页>新闻中心>viber

C# 创坐Word项目标号列表、多级编号列表-Mia张

時間:2022-12-10   訪問量:2757

一、 创坐项目标号列表

VB.NET


  1. Imports Spire.Doc

  2. Imports Spire.Doc.Documents


  3. Namespace WordBullets


  4.     Class Program


  5.         Private Shared Sub Main(ByVal args As String())

  6.             Dim doc As Document = New Document()

  7.             Dim section As Section = doc.AddSection()

  8.             Dim para1 As Paragraph = section.AddParagraph()

  9.             para1.AppendText("国际政治类组织")

  10.             Dim para2 As Paragraph = section.AddParagraph()

  11.             para2.AppendText("欧洲联盟(欧盟)")

  12.             Dim para3 As Paragraph = section.AddParagraph()

  13.             para3.AppendText("自力国家疏散体(独联体)")

  14.             Dim para4 As Paragraph = section.AddParagraph()

  15.             para4.AppendText("上海开做组织")

  16.             Dim para5 As Paragraph = section.AddParagraph()

  17.             para5.AppendText("阿推伯聚会会议联盟")

  18.             Dim para6 As Paragraph = section.AddParagraph()

  19.             para6.AppendText("国际死态战仄开做组织")

  20.             Dim para7 As Paragraph = section.AddParagraph()

  21.             para7.AppendText("阿推伯国家联盟")

  22.             Dim style As ParagraphStyle = New ParagraphStyle(doc)

  23.             style.Name = "fontStyle"

  24.             style.CharacterFormat.FontName = "宋体"

  25.             style.CharacterFormat.FontSize = 12F

  26.             doc.Styles.Add(style)

  27.             For i As Integer = 0 To section.Paragraphs.Count - 1

  28.                 If i <> 0 Then

  29.                     section.Paragraphs(i).ApplyStyle(BuiltinStyle.ListBullet2)

  30.                 End If


  31.                 section.Paragraphs(i).ApplyStyle("fontStyle")

  32.             Next


  33.             doc.SaveToFile("项目列表.docx", FileFormat.Docx2013)

  34.             System.Diagnostics.Process.Start("项目列表.docx")

  35.         End Sub

  36.     End Class

  37. End Namespace



C#

  1. using Spire.Doc;

  2. using Spire.Doc.Documents;

  3. using Spire.Doc.Fields;


  4. namespace Multi_levelList_Doc

  5. {

  6.     class Program

  7.     {

  8.         static void Main(string[] args)

  9.         {

  10.             //新建Word文档

  11.             Document doc = new Document();

  12.             Section section = doc.AddSection();


  13.             //初初化ListStyle工具,指定List类型为数字列表并命名

  14.             ListStyle listStyle = new ListStyle(doc, ListType.Numbered);

  15.             listStyle.Name = "levelstyle";


  16.             //设定一级列表形式为阿推伯数字

  17.             listStyle.Levels[0].PatternType = ListPatternType.Arabic;


  18.             //设置两级列表数字前缀及形式

  19.             listStyle.Levels[1].NumberPrefix = ".";

  20.             listStyle.Levels[1].PatternType = ListPatternType.Arabic;


  21.             //设置三级列表数字前缀及形式

  22.             listStyle.Levels[2].NumberPrefix = "..";

  23.             listStyle.Levels[2].PatternType = ListPatternType.Arabic;


  24.             //正在ListStyles汇开中增减新建的list style

  25.             doc.ListStyles.Add(listStyle);


  26.             //创坐字体格式

  27.             Spire.Doc.Formatting.CharacterFormat format = new Spire.Doc.Formatting.CharacterFormat(doc);

  28.             format.FontName = "宋体";


  29.             //增减段降,设置一级序列

  30.             Paragraph paragraph = section.AddParagraph();

  31.             TextRange tr = paragraph.AppendText("次要组织机构");

  32.             tr.ApplyCharacterFormat(format); //应用字体格式

  33.             paragraph.ApplyStyle(BuiltinStyle.Heading1); //应用题目1花式

  34.             paragraph.ListFormat.ApplyStyle("levelstyle"); //应用列表花式


  35.             //增减段降,设置一级序列

  36.             paragraph = section.AddParagraph();

  37.             tr = paragraph.AppendText("次要本能性能");

  38.             tr.ApplyCharacterFormat(format);

  39.             paragraph.ApplyStyle(BuiltinStyle.Heading1);

  40.             paragraph.ListFormat.ApplyStyle("levelstyle");


  41.             //增减段降,设置两级序列

  42.             paragraph = section.AddParagraph();

  43.             tr = paragraph.AppendText("根柢本能性能");

  44.             tr.ApplyCharacterFormat(format);

  45.             paragraph.ApplyStyle(BuiltinStyle.Heading2);

  46.             paragraph.ListFormat.ListLevelNumber = 1; //设置品级为第两品级

  47.             paragraph.ListFormat.ApplyStyle("levelstyle");


  48.             //增减段降,设置两级序列

  49.             paragraph = section.AddParagraph();

  50.             tr = paragraph.AppendText("5年夜本能性能");

  51.             tr.ApplyCharacterFormat(format);

  52.             paragraph.ApplyStyle(BuiltinStyle.Heading2);

  53.             paragraph.ListFormat.ContinueListNumbering();

  54.             paragraph.ListFormat.ApplyStyle("levelstyle");


  55.             //增减段降,设置三级序列

  56.             paragraph = section.AddParagraph();

  57.             tr = paragraph.AppendText("办理本能性能 组织本能性能 协调本能性能 疗养本能性能 供给本能性能");

  58.             tr.ApplyCharacterFormat(format);

  59.             paragraph.ApplyStyle(BuiltinStyle.Heading5);

  60.             paragraph.ListFormat.ListLevelNumber = 2; //设置品级为第三品级

  61.             paragraph.ListFormat.ApplyStyle("levelstyle");


  62.             //增减段降,设置一级序列

  63.             paragraph = section.AddParagraph();

  64.             tr = paragraph.AppendText("根前导收端根底则");

  65.             tr.ApplyCharacterFormat(format);

  66.             paragraph.ApplyStyle(BuiltinStyle.Heading1);

  67.             paragraph.ListFormat.ApplyStyle("levelstyle");


  68.             //留存并打开文档

  69.             doc.SaveToFile("多级列表.docx", FileFormat.Docx);

  70.             System.Diagnostics.Process.Start("多级列表.docx");

  71.         }

  72.     }

  73. }


创坐成果(截图):



VB.NET

  1. Imports Spire.Doc

  2. Imports Spire.Doc.Documents

  3. Imports Spire.Doc.Fields


  4. Namespace Multi_levelList_Doc


  5.     Class Program


  6.         Private Shared Sub Main(ByVal args As String())

  7.             Dim doc As Document = New Document()

  8.             Dim section As Section = doc.AddSection()

  9.             Dim listStyle As ListStyle = New ListStyle(doc, ListType.Numbered)

  10.             listStyle.Name = "levelstyle"

  11.             listStyle.Levels(0).PatternType = ListPatternType.Arabic

  12.             listStyle.Levels(1).NumberPrefix = vbNullChar & "."

  13.             listStyle.Levels(1).PatternType = ListPatternType.Arabic

  14.             listStyle.Levels(2).NumberPrefix = vbNullChar & "." & ChrW(1) & "."

  15.             listStyle.Levels(2).PatternType = ListPatternType.Arabic

  16.             doc.ListStyles.Add(listStyle)

  17.             Dim format As Spire.Doc.Formatting.CharacterFormat = New Spire.Doc.Formatting.CharacterFormat(doc)

  18.             format.FontName = "宋体"

  19.             Dim paragraph As Paragraph = section.AddParagraph()

  20.             Dim tr As TextRange = paragraph.AppendText("次要组织机构")

  21.             tr.ApplyCharacterFormat(format)

  22.             paragraph.ApplyStyle(BuiltinStyle.Heading1)

  23.             paragraph.ListFormat.ApplyStyle("levelstyle")

  24.             paragraph = section.AddParagraph()

  25.             tr = paragraph.AppendText("次要本能性能")

  26.             tr.ApplyCharacterFormat(format)

  27.             paragraph.ApplyStyle(BuiltinStyle.Heading1)

  28.             paragraph.ListFormat.ApplyStyle("levelstyle")

  29.             paragraph = section.AddParagraph()

  30.             tr = paragraph.AppendText("根柢本能性能")

  31.             tr.ApplyCharacterFormat(format)

  32.             paragraph.ApplyStyle(BuiltinStyle.Heading2)

  33.             paragraph.ListFormat.ListLevelNumber = 1

  34.             paragraph.ListFormat.ApplyStyle("levelstyle")

  35.             paragraph = section.AddParagraph()

  36.             tr = paragraph.AppendText("5年夜本能性能")

  37.             tr.ApplyCharacterFormat(format)

  38.             paragraph.ApplyStyle(BuiltinStyle.Heading2)

  39.             paragraph.ListFormat.ContinueListNumbering()

  40.             paragraph.ListFormat.ApplyStyle("levelstyle")

  41.             paragraph = section.AddParagraph()

  42.             tr = paragraph.AppendText("办理本能性能 " & vbLf & " 组织本能性能 " & vbLf & " 协调本能性能 " & vbLf & " 疗养本能性能 " & vbLf & " 供给本能性能")

  43.             tr.ApplyCharacterFormat(format)

  44.             paragraph.ApplyStyle(BuiltinStyle.Heading5)

  45.             paragraph.ListFormat.ListLevelNumber = 2

  46.             paragraph.ListFormat.ApplyStyle("levelstyle")

  47.             paragraph = section.AddParagraph()

  48.             tr = paragraph.AppendText("根前导收端根底则")

  49.             tr.ApplyCharacterFormat(format)

  50.             paragraph.ApplyStyle(BuiltinStyle.Heading1)

  51.             paragraph.ListFormat.ApplyStyle("levelstyle")

  52.             doc.SaveToFile("多级列表.docx", FileFormat.Docx)

  53.             System.Diagnostics.Process.Start("多级列表.docx")

  54.         End Sub

  55.     End Class

  56. End Namespace

<span style="color:#3D464D;font-family:" white-space:normal;background-color:#ffffff;"="">感开冲动阅读!



                                 

Tag:

上一篇:C# 如何创坐、读与PDF文件-Mia张

下一篇:viber营销快速引流技术



联系客服

電报客服咨詢

電报信息公布群

联系客服
返回頂部