翻譯|使用教程|編輯:胡濤|2022-06-30 13:41:53.867|閱讀 221 次
概述:本指南中的解決方案介紹了如何在 C# 和 VB.NET 中插入和格式化 Word 頁(yè)面邊框。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Word 頁(yè)面邊框是頁(yè)面背景的一部分,用于美化文檔外觀。本指南中的解決方案介紹了如何在 C# 和 VB.NET 中插入和格式化 Word 頁(yè)面邊框。
MS Word 使用戶能夠裝飾 Word 頁(yè)面以獲得更好的布局或外觀。頁(yè)面邊框的所有格式都可以自定義,包括樣式、顏色、寬度、邊距等。本指南演示如何為 Word 文檔添加頁(yè)面邊框,并通過(guò)Spire.Doc for .NET在 C# 和 VB.NET 中對(duì)其進(jìn)行格式化。以下屏幕截圖顯示了編程后帶有頁(yè)面邊框的 Word。
Spire.Doc for .NET 提供Section類,允許您創(chuàng)建新的部分實(shí)例或操作現(xiàn)有的部分。Borders是Section 類的PageSetup的屬性之一。您可以直接設(shè)置Borders 的BorderType屬性來(lái)添加頁(yè)面邊框并設(shè)置Color , Space of Left/Right屬性來(lái)格式化邊框。.NET 的 Spire.Doc 提供的邊框類型包括 None、Single、Thick、Double、Hairline、Dot、DashLargeGap、DotDash、DotDotDash、Triple、ThinkThickSmallGap、ThinThinSampllGap、ThinThickThinSamllGap、ThickThickMediumGap、ThickThinMediumGap、ThickThickThinMediumGap、ThickThickLargeThickThick、ThickThinLargeGap、WaveGap、 , DoubleWave, DashSamllGap, DashDotStroker, Emboss3D, Engrave3D, Outset, Inset, TwistedLines1, 清除。在本例中,邊框類型設(shè)置為 DoubleWave。
下載并安裝 Spire.Doc for .NET并遵循以下代碼:
[C#]
using System.Drawing; using Spire.Doc; using Spire.Doc.Documents; namespace WordBorder { class PageBorders { static void Main(string[] args) { //Load Document Document document = new Document(); document.LoadFromFile(@"E:\Work\Documents\Microsoft Word 2013 Preview.docx"); Section section = document.Sections[0]; //Add Page Borders with Special Style and Color section.PageSetup.Borders.BorderType = BorderStyle.DoubleWave; section.PageSetup.Borders.Color = Color.LightSeaGreen; //Space between Border and Text section.PageSetup.Borders.Left.Space = 50; section.PageSetup.Borders.Right.Space = 50; //Save and Launch document.SaveToFile("PageBorders.docx", FileFormat.Docx); System.Diagnostics.Process.Start("PageBorders.docx"); } } }
[VB.NET]
Imports System.Drawing Imports Spire.Doc Imports Spire.Doc.Documents Namespace WordBorder Friend Class PageBorders Shared Sub Main(ByVal args() As String) 'Load Document Dim document As New Document() document.LoadFromFile("E:\Work\Documents\Microsoft Word 2013 Preview.docx") Dim section As Section = document.Sections(0) 'Add Page Borders with Special Style and Color section.PageSetup.Borders.BorderType = BorderStyle.DoubleWave section.PageSetup.Borders.Color = Color.LightSeaGreen 'Space between Border and Text section.PageSetup.Borders.Left.Space = 50 section.PageSetup.Borders.Right.Space = 50 'Save and Launch document.SaveToFile("PageBorders.docx", FileFormat.Docx) System.Diagnostics.Process.Start("PageBorders.docx") End Sub End Class End Namespace
Spire.Doc 是一個(gè)獨(dú)立的組件,使開(kāi)發(fā)人員/程序員能夠在WPF、.NET和Silverlight中生成、打開(kāi)、編寫、編輯和保存 Word 文檔,而無(wú)需在系統(tǒng)上安裝 Microsoft Word。
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請(qǐng)咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn