文檔半島外圍網上直營>>E-iceblue中文文檔>>將文本分成兩列并在它們之間添加行
                將文本分成兩列并在它們之間添加行
列被廣泛用于設置頁面布局,它可以將文本分成兩列或多列,以便文本可以在同一頁面上從一列流到下一列。使用 Spire.Doc,我們可以實現此功能并同時在列之間添加一條線。本文將介紹如何將文本拆分為兩列并在它們之間添加行。
注意:請下載最新版本的 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");
}
}
}
                
            
 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線