在word文檔中設置段落間距
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 最新下載
段落是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產品
獲取更多信息請咨詢 ;技術交流Q群(767755948)


 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線