Word控件Spire.Doc 【文本】教程(11) ;如何将文本分成两列并在它们之间添加行

列被广泛用于设置页面布局,它可以将文本分成两列或多列,以便文本可以在同一页面上从一列流到下一列。使用 Spire.Doc,我们可以实现此功能并同时在列之间添加一条线。本文将介绍如何将文本拆分为两列并在它们之间添加行。

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

注意:请下载最新版本的 Spire.Doc 并添加 Spire.Doc .dll 作为 Visual Studio 的参考。

第 1 步:创建一个新文档并从文件加载

Document document = new Document();
document.LoadFromFile("S.docx");

步骤 2:在第一节添加一列,设置列宽和列间距。这里我们将宽度设置为 100f,间距设置为 20f。

document.Sections[0].AddColumn(100f, 20f);

document.Sections[0].AddColumn(100f, 20f);

第 3 步:在两列之间添加一条线

document.Sections[0].PageSetup.ColumnsLineBetween = true;

第 4 步:保存文件并启动查看效果

document.SaveToFile("result.docx",FileFormat.docx2013);
System.Diagnostics.Process.Start("result.docx");

添加列之前:

效果

完整代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Doc;

namespace Column
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();

document.LoadFromFile("S.docx");

document.Sections[0].AddColumn(100f, 20f);

document.Sections[0].PageSetup.ColumnsLineBetween = true;

document.SaveToFile("result.docx",FileFormat.docx2013);
System.Diagnostics.Process.Start("result.docx");

}
}
}


如有您有产品试用,授权等相关问题,欢迎私聊我获取~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值