在word文檔中設(shè)置段落間距
Spire.Doc for .NET是一款專門(mén)對(duì) Word 文檔進(jìn)行操作的 .NET 類庫(kù)。在于幫助開(kāi)發(fā)人員無(wú)需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開(kāi)發(fā)經(jīng)驗(yàn)Spire系列辦公文檔開(kāi)發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
E-iceblue 功能類庫(kù)Spire 系列文檔處理組件均由中國(guó)本土團(tuán)隊(duì)研發(fā),不依賴第三方軟件,不受其他國(guó)家的技術(shù)或法律法規(guī)限制,同時(shí)適配國(guó)產(chǎn)操作系統(tǒng)如中科方德、中標(biāo)麒麟等,兼容國(guó)產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
Spire.Doc for.NET 最新下載
段落是word文檔中非常重要的元素。它功能強(qiáng)大并且具有許多特性。Spire.Doc 是專為開(kāi)發(fā)人員設(shè)計(jì)的 .NET 組件,可讓您輕松靈活地操作段落。
我們網(wǎng)站上有介紹如何設(shè)置對(duì)齊、縮進(jìn)和項(xiàng)目符號(hào)的文檔。這篇文章向您介紹了如何在word文檔中設(shè)置段落間距。
第一步:創(chuàng)建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 步:設(shè)置第一段的行距。
paragraph.Format.LineSpacing = 20;
第4步:設(shè)置第一段的間距。
paragraph.Format.BeforeSpacing = 30;
第 5 步:設(shè)置第一段之后的間距
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");
}
}
}
截圖:
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請(qǐng)咨詢 ;技術(shù)交流Q群(767755948)


QQ交談
在線咨詢

渝公網(wǎng)安備
50010702500608號(hào)

客服熱線