精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網站建設資訊

NEWS

網站建設資訊

C#創建Word項目標號列表、多級編號列表-創新互聯

在Word文檔中,對于有多條并列的信息內容或者段落時,我們常以添加項目標號的形式來使文檔條理化,在閱讀時,文檔也更具美觀性。另外,對于在邏輯上存在一定層級結構的內容時,也可以通過多級編號列表來標明文檔內容的層次,并且,在修改、編輯文檔時也增加了靈活性。因此,在本篇文檔中,將介紹如何在C#中通過使用類庫Free Spire.Doc for .NET 來創建項目編號列表和多級編號列表的方法。
使用工具: Free Spire.Doc for .NET(社區版)
使用方法:在安裝該類庫后,在項目中引用Spire.Doc.dll即可(dll文件可在安裝路徑下的Bin文件夾中獲取)

專注于為中小企業提供成都網站制作、成都做網站、外貿營銷網站建設服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業合水免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了上1000+企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。

一、 創建項目標號列表

C#

using Spire.Doc;
using Spire.Doc.Documents;

namespace WordBullets
{
    class Program
    {
        static void Main(string[] args)
        {
            //初始化Document類實例,并添加section
            Document doc = new Document();
            Section section = doc.AddSection();

            //添加七個段落并分別添加文字
            Paragraph para1 = section.AddParagraph();
            para1.AppendText("國際政治類組織");
            Paragraph para2 = section.AddParagraph();
            para2.AppendText("歐洲聯盟(歐盟)");
            Paragraph para3 = section.AddParagraph();
            para3.AppendText("獨立國家聯合體(獨聯體)");
            Paragraph para4 = section.AddParagraph();
            para4.AppendText("上海合作組織");
            Paragraph para5 = section.AddParagraph();
            para5.AppendText("阿拉伯會議聯盟");
            Paragraph para6 = section.AddParagraph();
            para6.AppendText("國際生態安全合作組織");
            Paragraph para7 = section.AddParagraph();
            para7.AppendText("阿拉伯國家聯盟");

            //創建段落格式(字體)
            ParagraphStyle style = new ParagraphStyle(doc);
            style.Name = "fontStyle";
            style.CharacterFormat.FontName = "宋體";
            style.CharacterFormat.FontSize = 12f;
            doc.Styles.Add(style);

            //遍歷所有段落
            for (int i = 0; i < section.Paragraphs.Count; i++)
            {
                //從第二段開始應用項目符號排列
                if (i != 0)
                {
                    section.Paragraphs[i].ApplyStyle(BuiltinStyle.ListBullet2);
                }

                //應用字體格式到每一段
                section.Paragraphs[i].ApplyStyle("fontStyle");

            }
            //保存并打開文檔
            doc.SaveToFile("項目列表.docx", FileFormat.Docx2013);
            System.Diagnostics.Process.Start("項目列表.docx");
        }
    }
}

測試結果:
C# 創建Word項目標號列表、多級編號列表

二、 創建多級編號列表

C#

using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace Multi_levelList_Doc
{
    class Program
    {
        static void Main(string[] args)
        {
            //新建Word文檔
            Document doc = new Document();
            Section section = doc.AddSection();

            //初始化ListStyle對象,指定List類型為數字列表并命名
            ListStyle listStyle = new ListStyle(doc, 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;

            //在ListStyles集合中添加新建的list style
            doc.ListStyles.Add(listStyle);

            //創建字體格式
            Spire.Doc.Formatting.CharacterFormat format = new Spire.Doc.Formatting.CharacterFormat(doc);
            format.FontName = "宋體";

            //添加段落,設置一級序列
            Paragraph paragraph = section.AddParagraph();
            TextRange tr = paragraph.AppendText("主要組織機構");
            tr.ApplyCharacterFormat(format); //應用字體格式
            paragraph.ApplyStyle(BuiltinStyle.Heading1); //應用標題1樣式
            paragraph.ListFormat.ApplyStyle("levelstyle"); //應用列表樣式

            //添加段落,設置一級序列
            paragraph = section.AddParagraph();
            tr = paragraph.AppendText("主要職能");
            tr.ApplyCharacterFormat(format);
            paragraph.ApplyStyle(BuiltinStyle.Heading1);
            paragraph.ListFormat.ApplyStyle("levelstyle");

            //添加段落,設置二級序列
            paragraph = section.AddParagraph();
            tr = paragraph.AppendText("基本職能");
            tr.ApplyCharacterFormat(format);
            paragraph.ApplyStyle(BuiltinStyle.Heading2);
            paragraph.ListFormat.ListLevelNumber = 1; //設置等級為第二等級
            paragraph.ListFormat.ApplyStyle("levelstyle");

            //添加段落,設置二級序列
            paragraph = section.AddParagraph();
            tr = paragraph.AppendText("5大職能");
            tr.ApplyCharacterFormat(format);
            paragraph.ApplyStyle(BuiltinStyle.Heading2);
            paragraph.ListFormat.ContinueListNumbering();
            paragraph.ListFormat.ApplyStyle("levelstyle");

            //添加段落,設置三級序列
            paragraph = section.AddParagraph();
            tr = paragraph.AppendText("管理職能 \n 組織職能 \n 協調職能 \n 調節職能 \n 提供職能");
            tr.ApplyCharacterFormat(format);
            paragraph.ApplyStyle(BuiltinStyle.Heading5);
            paragraph.ListFormat.ListLevelNumber = 2; //設置等級為第三等級
            paragraph.ListFormat.ApplyStyle("levelstyle");

            //添加段落,設置一級序列
            paragraph = section.AddParagraph();
            tr = paragraph.AppendText("基本原則");
            tr.ApplyCharacterFormat(format);
            paragraph.ApplyStyle(BuiltinStyle.Heading1);
            paragraph.ListFormat.ApplyStyle("levelstyle");

            //保存并打開文檔
            doc.SaveToFile("多級列表.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("多級列表.docx");
        }
    }
}

測試結果:
C# 創建Word項目標號列表、多級編號列表

以上代碼供參考,歡迎轉載(轉載請注明出處)。
感謝閱讀!

另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。


標題名稱:C#創建Word項目標號列表、多級編號列表-創新互聯
網站網址:http://m.jcarcd.cn/article/dijjhe.html
主站蜘蛛池模板: 国产精品第44页 | 福利研究所导航 | 日本在线播放一区 | 欧美日韩综合在线 | 精品日韩第56页 | 日韩用力 | 国产农村一 | 国产人成中文字幕 | 欧美亚洲a∨中文 | 国产亚洲久一区二区 | 福利站导航 | 欧美日韩午夜激情 | 日本不卡高清视频 | 欧美日韩第一区 | 不卡在线一区 | 海派阅读 | 国产福利91网在 | 韩国欧洲一级 | 国产卡二卡三卡四卡 | 国产性爱一级 | 99re在线视| 精品欧美亚 | 国产在线午夜 | 精品国产综合区久 | 福利影视 | 福利免费视频在线 | 精品偷拍视频一区 | 成人国产一区二 | 蜜桃成熟时33d | 日韩午夜视频 | 成人福利免费看 | 国产精品在线二三区 | 欧亚欧洲码国产 | 国产又大 | 国产乱伦免 | 三区在线观看不卡 | 日韩国产欧美制服 | 91国产精品福利 | 精品国自产拍网站 | 蜜桃传媒视频 | 区三区影院视频 |