• <menu id="w2i4a"></menu>
  • logo E-iceblue中文文檔

    文檔首頁>>E-iceblue中文文檔>>創(chuàng)建多級列表編號

    創(chuàng)建多級列表編號


    Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。 

    E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時適配國產(chǎn)操作系統(tǒng)如中科方德、中標麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式

    Spire.Doc for.NET 最新下載

    多級列表編號允許您使用嵌套編號格式化和組織文本。多級列表最常見的形式是標題編號,它用大綱列表概括整篇文章,經(jīng)常出現(xiàn)在技術(shù)、學(xué)術(shù)和商業(yè)文檔中。在本文中,您將學(xué)習(xí)如何在 C#、VB.NET 中使用 Spire.Doc 生成多級列表編號。

    詳細步驟:

    第 1 步 : 創(chuàng)建一個新的 Word 文檔,添加一個部分。

    Document document = new Document();
    Section section = document.AddSection();

    第 2 步定義新的多級列表樣式。設(shè)置其名稱為levelstyle,設(shè)置ListType 為Numbered,設(shè)置level屬性的參數(shù)。此列表級別獨立于樣式運行并控制數(shù)字格式。

    ListStyle listStyle = new ListStyle(document, ListType.Numbered);
    listStyle.Name = "levelstyle";
    listStyle.Levels[0].PatternType = ListPatternType.Arabic;
    listStyle.Levels[1].NumberPrefix = "\x0000.";
    listStyle.Levels[1].PatternType = ListPatternType.Arabic;
    listStyle.Levels[2].NumberPrefix = "\x0000.\x0001.";
    listStyle.Levels[2].PatternType = ListPatternType.Arabic;
    document.ListStyles.Add(listStyle);

    第 3 步創(chuàng)建一個段落,將文本附加到段落并使用 Heading1 應(yīng)用段落樣式。將定義的列表樣式“l(fā)evelstyle”應(yīng)用于此段落。

    Paragraph paragraph = section.AddParagraph();
    paragraph.AppendText("The first item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");

    第 4 步重復(fù)第 3 步以向該文檔添加更多段落。在這里,您需要將不同的 ListLevelNumber 設(shè)置為 1 或 2,以確保將子段落和子段落分配給不同的列表模板。

    paragraph = section.AddParagraph();
    paragraph.AppendText("The second item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The first sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading2);
    paragraph.ListFormat.ListLevelNumber = 1;
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The second sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading2);
    paragraph.ListFormat.ContinueListNumbering();
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("A sub-sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading5);
    paragraph.ListFormat.ListLevelNumber = 2;
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The third item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");

    第 5 步保存文件。

    公文。SaveToFile(@“result.docx”, FileFormat.Docx);

    結(jié)果

    How to Create Multi-level List Numbering in Word in C#, VB.NET

    完整代碼

    [C#]

    using Spire.Doc;
    using Spire.Doc.Documents;
    namespace CreatList
    {
    class Program
    {
    
    static void Main(string[] args)
    {
    Document document = new Document();
    Section section = document.AddSection();
    
    ListStyle listStyle = new ListStyle(document, ListType.Numbered);
    listStyle.Name = "levelstyle";
    listStyle.Levels[0].PatternType = ListPatternType.Arabic;
    listStyle.Levels[1].NumberPrefix = "\x0000.";
    listStyle.Levels[1].PatternType = ListPatternType.Arabic;
    listStyle.Levels[2].NumberPrefix = "\x0000.\x0001.";
    listStyle.Levels[2].PatternType = ListPatternType.Arabic;
    document.ListStyles.Add(listStyle);
    
    Paragraph paragraph = section.AddParagraph();
    paragraph.AppendText("The first item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The second item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The first sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading2);
    paragraph.ListFormat.ListLevelNumber = 1;
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The second sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading2);
    paragraph.ListFormat.ContinueListNumbering();
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("A sub-sub-item");
    paragraph.ApplyStyle(BuiltinStyle.Heading5);
    paragraph.ListFormat.ListLevelNumber = 2;
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    paragraph = section.AddParagraph();
    paragraph.AppendText("The third item");
    paragraph.ApplyStyle(BuiltinStyle.Heading1);
    paragraph.ListFormat.ApplyStyle("levelstyle");
    
    document.SaveToFile(@"result.docx", FileFormat.Docx);
    
    }
    }
    }

    [VB.NET]

    Imports Spire.Doc
    Imports Spire.Doc.Documents
    Namespace CreatList
    Class Program
    
    Private Shared Sub Main(args As String())
    Dim document As New Document()
    Dim section As Section = document.AddSection()
    
    Dim listStyle As New ListStyle(document, ListType.Numbered)
    listStyle.Name = "levelstyle"
    listStyle.Levels(0).PatternType = ListPatternType.Arabic
    listStyle.Levels(1).NumberPrefix = vbNullChar & "."
    listStyle.Levels(1).PatternType = ListPatternType.Arabic
    listStyle.Levels(2).NumberPrefix = vbNullChar & "." & ChrW(1) & "."
    listStyle.Levels(2).PatternType = ListPatternType.Arabic
    document.ListStyles.Add(listStyle)
    
    Dim paragraph As Paragraph = section.AddParagraph()
    paragraph.AppendText("The first item")
    paragraph.ApplyStyle(BuiltinStyle.Heading1)
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    paragraph = section.AddParagraph()
    paragraph.AppendText("The second item")
    paragraph.ApplyStyle(BuiltinStyle.Heading1)
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    paragraph = section.AddParagraph()
    paragraph.AppendText("The first sub-item")
    paragraph.ApplyStyle(BuiltinStyle.Heading2)
    paragraph.ListFormat.ListLevelNumber = 1
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    paragraph = section.AddParagraph()
    paragraph.AppendText("The second sub-item")
    paragraph.ApplyStyle(BuiltinStyle.Heading2)
    paragraph.ListFormat.ContinueListNumbering()
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    paragraph = section.AddParagraph()
    paragraph.AppendText("A sub-sub-item")
    paragraph.ApplyStyle(BuiltinStyle.Heading5)
    paragraph.ListFormat.ListLevelNumber = 2
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    paragraph = section.AddParagraph()
    paragraph.AppendText("The third item")
    paragraph.ApplyStyle(BuiltinStyle.Heading1)
    paragraph.ListFormat.ApplyStyle("levelstyle")
    
    document.SaveToFile("result.docx", FileFormat.Docx)
    
    End Sub
    End Class
    End Namespace

    以上便是通過Spire.Doc將Doc轉(zhuǎn)換為PDF時如何使用卸載的字體的教程,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。


    歡迎下載|體驗更多E-iceblue產(chǎn)品

    獲取更多信息請咨詢慧都在線客服  ;技術(shù)交流Q群(767755948)


    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();