翻譯|使用教程|編輯:顏馨|2023-04-13 09:33:24.570|閱讀 115 次
概述:本文介紹如何使用 Spire.Doc for .NET 在段落中放置腳注,歡迎查閱!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發人員無需安裝 Microsoft Word情況下,輕松快捷高效地創建、編輯、轉換和打印 Microsoft Word 文檔。擁有近10年專業開發經驗Spire系列辦公文檔開發工具,專注于創建、編輯、轉換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發,不依賴第三方軟件,不受其他國家的技術或法律法規限制,同時適配國產操作系統如中科方德、中標麒麟等,兼容國產文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
本文介紹如何使用 Spire.Doc for .NET 在段落中放置腳注,例如,在以下示例中的單詞"Spire.Doc":
步驟1:加載word文檔,示例.docx。
Document document1 = new Document(); document1.LoadFromFile("D:\\Sample.docx",FileFormat.Docx2010);
步驟2:獲取示例文檔第一部分的第一段。
Paragraph paragraph1 = document1.Sections[0].Paragraphs[0];
步驟3:在第1段中添加腳注。
Footnote footnote1 = paragraph1.AppendFootnote(FootnoteType.Footnote);
第 4 步:找到單詞“Spire.Doc”并在它后面插入腳注 1。
DocumentObject obj=null; for (int i = 0; i < paragraph1.ChildObjects.Count; i++) { obj=paragraph1.ChildObjects[i]; if (obj.DocumentObjectType == DocumentObjectType.TextRange) { TextRange textRange = obj as TextRange; // Find the word "Spire.Doc" in paragraph1 if (textRange.Text == "Spire.Doc") { //Set bold format for the word "Spire.Doc" textRange.CharacterFormat.Bold = true; //Insert footnote1 after the word "Spire.Doc" paragraph1.ChildObjects.Insert(i + 1, footnote1); break; } } }
步驟5:鍵入腳注1文本并設置文本的字體名稱,字體大小和顏色。
TextRange text = footnote1.TextBody.AddParagraph().AppendText("Welcome to evaluate Spire.Doc"); text.CharacterFormat.FontName = "Arial Black"; text.CharacterFormat.FontSize = 10; text.CharacterFormat.TextColor = Color.DarkGray;
步驟6:為腳注1編號設置字體名稱,字體大小,粗體和顏色。
footnote1.MarkerCharacterFormat.FontName = "Calibri"; footnote1.MarkerCharacterFormat.FontSize = 12; footnote1.MarkerCharacterFormat.Bold = true; footnote1.MarkerCharacterFormat.TextColor = Color.DarkGreen;
步驟 7:將示例.docx保存到新文檔 Footnote.docx。
document1.SaveToFile("D:\\ Footnote.docx"", FileFormat.Docx2010);
完整代碼:
Document document1 = new Document(); document1.LoadFromFile("D:\\Sample.docx" ,FileFormat.Docx2010); Paragraph paragraph 1= document1.Sections[0].Paragraphs[0]; Footnote footnote1 = paragraph.AppendFootnote(FootnoteType.Footnote); DocumentObject obj=null; for (int i = 0; i < paragraph1.ChildObjects.Count; i++) { obj=paragraph1.ChildObjects[i]; if (obj.DocumentObjectType == DocumentObjectType.TextRange) { TextRange textRange = obj as TextRange; // Find the word "Spire.Doc" in paragraph1 if (textRange.Text == "Spire.Doc") { //Set bold format for the word "Spire.Doc" textRange.CharacterFormat.Bold = true; //Insert footnote1 after the word "Spire.Doc" paragraph1.ChildObjects.Insert(i + 1, footnote1); break; } } } TextRange text = footnote1.TextBody.AddParagraph().AppendText("Welcome to evaluate Spire.Doc"); text.CharacterFormat.FontName = "Arial Black"; text.CharacterFormat.FontSize = 10; text.CharacterFormat.TextColor = Color.DarkGray; footnote1.MarkerCharacterFormat.FontName = "Calibri"; footnote1.MarkerCharacterFormat.FontSize = 12; footnote1.MarkerCharacterFormat.Bold = true; footnote1.MarkerCharacterFormat.TextColor = Color.DarkGreen; document1.SaveToFile("Footnote.docx",FileFormat.Docx2010);
以上便是如何在段落中插入腳注的教程,如果您有其他問題也可以繼續瀏覽本系列文章,獲取相關教程,你還可以給我留言或者加入我們的官方技術交流群。
歡迎下載|體驗更多E-iceblue產品
獲取更多信息請咨詢 ;技術交流Q群(767755948)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn