翻譯|使用教程|編輯:胡濤|2022-05-11 16:02:08.717|閱讀 321 次
概述:本文主要介紹了如何在word文檔中設置段落間距,歡迎查閱!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
段落是word文檔中非常重要的元素。它功能強大并且具有許多特性。Spire.Doc 是專為開發人員設計的 .NET 組件,可讓您輕松靈活地操作段落。
我們網站上有介紹如何設置對齊、縮進和項目符號的文檔。這篇文章向您介紹了如何在word文檔中設置段落間距。
第一步:創建word文檔。
Document document = new Document(); Section section = document.AddSection();
第 2 步:將第一段添加到文檔中。
Paragraph paragraph = section.AddParagraph(); paragraph.AppendText("Thank you for requesting a trial version of Spire.Doc. The component will work normally except for an evaluation warning message. Once you purchase a license file, the evaluation warning will disappeare.");
第 3 步:設置第一段的行距。
paragraph.Format.LineSpacing = 20;
第4步:設置第一段的間距。
paragraph.Format.BeforeSpacing = 30;
第 5 步:設置第一段之后的間距
paragraph.Format.AfterSpacing = 15;
第 6 步:保存文檔。
document.SaveToFile("result.doc", FileFormat.Doc);
完整代碼:
using Spire.Doc; using Spire.Doc.Documents; namespace Spacing { class Program { static void Main(string[] args) { Document document = new Document(); Section section = document.AddSection(); //add the first paragraph Paragraph paragraph = section.AddParagraph(); paragraph.AppendText("Thank you for requesting a trial version of Spire.Doc. The component will work normally except for an evaluation warning message. Once you purchase a license file, the evaluation warning will disappeare."); paragraph.Format.FirstLineIndent = 20; //set the Line spacing paragraph.Format.LineSpacing = 20; //set the Spacing Before paragraph.Format.BeforeSpacing = 30; //set the Spacing After paragraph.Format.AfterSpacing = 15; //add the second paragraph Paragraph paragraph2 = section.AddParagraph(); paragraph2.AppendText("Spire.Doc (Pack) is a compilation of Spire.Doc for .NET, Spire.Doc for Silverlight and Spire.Doc for WPF. It is a professional and powerful Word component which enables you to generate, load, write, edit and save Word document on .NET, Silverlight and WPF. With Spire.Doc, you can create a large range of applications."); paragraph2.Format.FirstLineIndent = 20; //set the Line spacing paragraph2.Format.LineSpacing = 25; //save the document document.SaveToFile("result.doc", FileFormat.Doc); System.Diagnostics.Process.Start("result.doc"); } } }
截圖:
歡迎下載|體驗更多E-iceblue產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn