Word控件Spire.Doc 【段落处理】教程(六):如何在word文档中设置段落间距

段落是word文档中非常重要的元素。它功能强大并且具有许多特性。Spire.Doc 是专为开发人员设计的 .NET 组件,可让您轻松灵活地操作段落。

Spire.Doc for.NET 最新下载icon-default.png?t=M7J4https://www.evget.com/product/3368/download

我们网站上有介绍如何设置对齐、缩进和项目符号的文档。这篇文章向您介绍了如何在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");

}
}
}

截图

 欢迎加入spire技术交流群:767755948

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
免费Spire.Doc for .NET是e-iceblue公司推出的一款专门对Microsoft Word 文档进行操作的.NET类件。这款件的主要功能在于帮助开发人员轻松快捷地生成、编辑和查看Word文档。同时,开发人员还可以通过使用Spire.Doc for .NET 设置Word文档的格式,插入图片,表格,超链接等。Spire.Doc for .NET 最大的便利之处在于它不依赖于Microsoft Word以及任何其他第三方软件。只需将此款件安装在您的电脑上,您就可以对word文档进行操作。此款件支持所有的Word格式,即Word97,Word2003,Word2007, Word2010以及Word2013。 主要功能: • 可生成、打开、查看、编辑以及保存Word文档。 • 可对word文档进行加密、解密、设置权限已达到保护Word文档的效果。 • 可对页面进行设置,包括页眉、页脚的设计,插入分页符等。 • 可对文档格式进行设置,包括字体(大小、颜色等)和段落(行间距、项目符号等)的格式设置。 • 可在word文档插入外部资源,如图片、超链接、水印、表格、批注等。 • 支持Word文档和其他文件格式间的转换。如Word to HTML/XML/PDF/EPub/RTF等。同时,其他格式也可以转换为Word,如HTML/XML/RTF/Text to WordWord不同版本间的格式也可相互转换,即Docx to Doc 或者Doc to Docx. • 支持邮件合并功能。开发人员可使用Spire.Doc for .NET提供的邮件合并功能轻松地完成对报表的批量设计及打印。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值