最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用C#代碼在Word文檔中插入列表的操作方法

 更新時(shí)間:2025年11月07日 09:15:27   作者:2501_93070778  
列表在 Word 文檔中用于概述、排列和強(qiáng)調(diào)文本,使用戶能夠輕松掃描和理解一系列項(xiàng)目,在本文中,您將學(xué)習(xí)如何使用 Spire.Doc for .NET 在 C# 和 VB.NET 中將這些類型的列表插入到 Word 文檔中,需要的朋友可以參考下

列表在 Word 文檔中用于概述、排列和強(qiáng)調(diào)文本,使用戶能夠輕松掃描和理解一系列項(xiàng)目。Word 中有三種不同類型的列表,分別是編號(hào)列表、項(xiàng)目符號(hào)列表和多級(jí)列表。編號(hào)列表用于表示具有順序或優(yōu)先級(jí)的項(xiàng)目,例如一系列的指示。項(xiàng)目符號(hào)列表用于表示沒有特定優(yōu)先級(jí)的項(xiàng)目,例如功能或事實(shí)列表。多級(jí)列表用于存在順序且希望每個(gè)段落單獨(dú)編號(hào)的情況。

在本文中,您將學(xué)習(xí)如何使用 Spire.Doc for .NET 在 C# 和 VB.NET 中將這些類型的列表插入到 Word 文檔中。

安裝 Spire.Doc for .NET

首先,您需要將 Spire.Doc for .NET 包中包含的 DLL 文件添加為 .NET 項(xiàng)目的引用。這些 DLL 文件可以通過此鏈接下載,或者通過 NuGet 安裝。

PM> Install-Package Spire.Doc

在 C# 和 VB.NET 中插入編號(hào)列表

Spire.Doc for .NET 提供了 ListStyle 類,您可以使用它來創(chuàng)建編號(hào)列表樣式或項(xiàng)目符號(hào)樣式。然后,可以通過 Paragraph.ListFormat.ApplyStyle() 方法將列表樣式應(yīng)用到段落中。

創(chuàng)建編號(hào)列表的示例代碼如下:

using Spire.Doc;
using Spire.Doc.Documents;
 
namespace CreateOrderedList
{
    class Program
    {
        static void Main(string[] args)
        {
            //創(chuàng)建一個(gè) Document 對(duì)象
            Document document = new Document();
            
            //添加一個(gè)節(jié)
            Section section = document.AddSection();
 
            //創(chuàng)建一個(gè)編號(hào)列表樣式
            ListStyle listStyle = new ListStyle(document, ListType.Numbered);
            listStyle.Name = "numberedList";
            listStyle.Levels[0].PatternType = ListPatternType.DecimalEnclosedParen;
            listStyle.Levels[0].TextPosition = 20;   
            document.ListStyles.Add(listStyle);
 
            //添加一個(gè)段落
            Paragraph paragraph = section.AddParagraph();
            paragraph.AppendText("Required Web Development Skills:");
            paragraph.Format.AfterSpacing = 5f;
 
            //添加一個(gè)段落并應(yīng)用編號(hào)列表樣式
            paragraph = section.AddParagraph();
            paragraph.AppendText("HTML");
            paragraph.ListFormat.ApplyStyle("numberedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            //添加另外四個(gè)段落并應(yīng)用編號(hào)列表樣式
            paragraph = section.AddParagraph();
            paragraph.AppendText("CSS");
            paragraph.ListFormat.ApplyStyle("numberedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("JavaScript");
            paragraph.ListFormat.ApplyStyle("numberedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("Python");
            paragraph.ListFormat.ApplyStyle("numberedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("MySQL");
            paragraph.ListFormat.ApplyStyle("numberedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            //保存結(jié)果文件
            document.SaveToFile("NumberedList.docx", FileFormat.Docx);
        }
    }
}

在 C# 和 VB.NET 中插入項(xiàng)目符號(hào)列表

創(chuàng)建項(xiàng)目符號(hào)列表的過程與創(chuàng)建編號(hào)列表類似。不同之處在于,在創(chuàng)建列表樣式時(shí),必須將列表類型指定為“項(xiàng)目符號(hào)”,并為其設(shè)置一個(gè)項(xiàng)目符號(hào)符號(hào)。以下是相關(guān)代碼示例:

using Spire.Doc;
using Spire.Doc.Documents;
 
namespace CreateUnorderedList
{
    class Program
    {
        static void Main(string[] args)
        {
            //創(chuàng)建一個(gè) Document 對(duì)象
            Document document = new Document();
 
            //添加一個(gè)節(jié)
            Section section = document.AddSection();
 
            //創(chuàng)建一個(gè)項(xiàng)目符號(hào)列表樣式
            ListStyle listStyle = new ListStyle(document, ListType.Bulleted);
            listStyle.Name = "bulletedList";
            listStyle.Levels[0].BulletCharacter = "\x00B7";
            listStyle.Levels[0].CharacterFormat.FontName = "Symbol";
            listStyle.Levels[0].TextPosition = 20;
            document.ListStyles.Add(listStyle);
 
            //添加一個(gè)段落
            Paragraph paragraph = section.AddParagraph();
            paragraph.AppendText("Computer Science Subjects:");
            paragraph.Format.AfterSpacing = 5f;
 
            //添加一個(gè)段落并應(yīng)用項(xiàng)目符號(hào)列表樣式
            paragraph = section.AddParagraph();
            paragraph.AppendText("Data Structure");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            //添加另外五個(gè)段落并應(yīng)用項(xiàng)目符號(hào)列表樣式
            paragraph = section.AddParagraph();
            paragraph.AppendText("Algorithm");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("Computer Networks");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("Operating System");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("C Programming");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            paragraph = section.AddParagraph();
            paragraph.AppendText("Theory of Computations");
            paragraph.ListFormat.ApplyStyle("bulletedList");
            paragraph.ListFormat.ListLevelNumber = 0;
 
            //保存結(jié)果文件
            document.SaveToFile("BulletedList.docx", FileFormat.Docx);
        }
    }
}

申請(qǐng)臨時(shí)許可證

如果您希望從生成的文檔中移除評(píng)估信息,或解除功能限制,請(qǐng)申請(qǐng)一份 30 天的試用許可證。

到此這篇關(guān)于使用C#代碼在Word文檔中插入列表的操作方法的文章就介紹到這了,更多相關(guān)C# Word插入列表內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#處理猜拳問題的簡(jiǎn)單實(shí)例(非窗體)

    C#處理猜拳問題的簡(jiǎn)單實(shí)例(非窗體)

    下面小編就為大家?guī)硪黄狢#處理猜拳問題的簡(jiǎn)單實(shí)例(非窗體)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-07-07
  • C#文件非占用讀取與幫助類FileHelper

    C#文件非占用讀取與幫助類FileHelper

    這篇文章介紹了C#文件非占用讀取與幫助類FileHelper,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • C# 引入委托的目的是什么

    C# 引入委托的目的是什么

    這篇文章主要介紹了C# 引入委托的目的是什么,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • 一文掌握C# ListView控件的用法和示例代碼

    一文掌握C# ListView控件的用法和示例代碼

    ListView控件提供了豐富的屬性和事件,可以用于實(shí)現(xiàn)各種各樣的表格視圖,包括帶有單元格編輯、排序和分組等功能,本文介紹了一些常見的?ListView?控件的用法和示例代碼,感興趣的朋友一起看看吧
    2024-02-02
  • C#中SQL Command的基本用法

    C#中SQL Command的基本用法

    今天小編就為大家分享一篇關(guān)于C#中SQL Command的基本用法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • Unity5.6大規(guī)模地形資源創(chuàng)建方法

    Unity5.6大規(guī)模地形資源創(chuàng)建方法

    這篇文章主要為大家詳細(xì)介紹了Unity5.6大規(guī)模地形資源創(chuàng)建方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-02-02
  • C# 實(shí)現(xiàn)連連看功能(推薦)

    C# 實(shí)現(xiàn)連連看功能(推薦)

    本文是利用C#實(shí)現(xiàn)連連看的小例子,使用線程thread實(shí)現(xiàn)后臺(tái)運(yùn)行時(shí)間控制,實(shí)現(xiàn)代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
    2017-07-07
  • word ppt excel文檔轉(zhuǎn)換成pdf的C#實(shí)現(xiàn)代碼

    word ppt excel文檔轉(zhuǎn)換成pdf的C#實(shí)現(xiàn)代碼

    這篇文章主要介紹了word ppt excel文檔轉(zhuǎn)換成pdf的C#實(shí)現(xiàn)代碼,有需要的朋友可以參考一下
    2014-01-01
  • 最新評(píng)論

    太湖县| 南靖县| 托克逊县| 常熟市| 南岸区| 海南省| 齐河县| 乌鲁木齐市| 沙河市| 邯郸市| 湖口县| 镇赉县| 炎陵县| 巢湖市| 丹棱县| 岚皋县| 武平县| 莱州市| 翁源县| 固原市| 克什克腾旗| 信丰县| 兴安县| 湖南省| 容城县| 工布江达县| 苏尼特右旗| 横峰县| 百色市| 改则县| 五莲县| 衡东县| 望江县| 花莲县| 轮台县| 炉霍县| 乡城县| 丹阳市| 广平县| 太康县| 丘北县|