本文實(shí)例為大家分享了C#添加讀取Word腳注尾注的具體代碼,供大家參考,具體內(nèi)容如下
腳注和尾注是對(duì)文本的補(bǔ)充說明。腳注一般位于頁(yè)面的底部,可以作為文檔某處內(nèi)容的注釋;尾注一般位于文檔的末尾,列出引文 的出處等。在本示例中將介紹如何來添加或刪除Word腳注。
工具使用: Free Spire. Doc for .NET(免費(fèi)版)
第一步:dll引用

第二步:添加Word腳注、尾注
【C#】
using Spire.Doc;using Spire.Doc.Documents;using Spire.Doc.Fields;using System.Drawing;namespace InsertFootnote_Doc{ class Program { static void Main(string[] args) { //新建一個(gè)word文檔對(duì)象并加載需要添加腳注尾注的word文檔 Document document = new Document(); document.LoadFromFile("sample.docx", FileFormat.Docx2010); //獲取第3個(gè)段落 Paragraph paragraph = document.Sections[0].Paragraphs[2]; //添加腳注 Footnote footnote = paragraph.AppendFootnote(FootnoteType.Footnote); //在第一段里查找指定字符串,并添加腳注 DocumentObject obj = null; for (int i = 0; i < paragraph.ChildObjects.Count; i++) { obj = paragraph.ChildObjects[i]; if (obj.DocumentObjectType == DocumentObjectType.TextRange) { TextRange textRange = obj as TextRange; if (textRange.Text == "中國(guó)――東盟自貿(mào)區(qū)框架") { //為添加腳注的字符串設(shè)置加粗格式 textRange.CharacterFormat.Bold = true; //插入腳注 paragraph.ChildObjects.Insert(i + 1, footnote); break; } } } //添加腳注內(nèi)容被設(shè)置字體格式 TextRange text = footnote.TextBody.AddParagraph().AppendText("2002年11月4日,朱
主站蜘蛛池模板:
恭城|
永年县|
东阳市|
洛宁县|
游戏|
雅江县|
涡阳县|
双柏县|
嘉兴市|
塔河县|
丰台区|
墨玉县|
南和县|
普兰县|
兴文县|
平顶山市|
常熟市|
墨竹工卡县|
山阴县|
涟水县|
扬州市|
肥东县|
嘉禾县|
水城县|
西贡区|
报价|
二连浩特市|
扶余县|
和龙市|
呼玛县|
澜沧|
鲁甸县|
南乐县|
巴马|
金华市|
焦作市|
谷城县|
泸州市|
建宁县|
尼勒克县|
满城县|