翻譯|使用教程|編輯:顏馨|2023-04-20 16:54:00.257|閱讀 262 次
概述:本章講述如何在C#, VB.NET中設(shè)置Word字體,歡迎查閱!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時適配國產(chǎn)操作系統(tǒng)如中科方德、中標(biāo)麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
Word 字體設(shè)置允許用戶更改文檔中的文本字體樣式和大小。通過精彩的字體設(shè)置,文檔布局和外觀將更具吸引力。更重要的是,為了使一些特殊的單詞,短語或段落更加明顯,用戶可以設(shè)置不同的字體樣式或大小。例如,標(biāo)題通常設(shè)置為不同的字體樣式,與正文的大小更大。
Spire.Doc for .NET是一個專業(yè)的.NET Word組件,使用戶可以在Word文檔中設(shè)置字體。本指南將展示如何通過Spire.Doc for .NET使用C#、VB.NET進行設(shè)置,以下是設(shè)置后的屏幕截圖。
[C#]
using Spire.Doc;
using Spire.Doc.Documents;
namespace WordImage
{
class ImageinWord
{
static void Main(string[] args)
{
//Load Document
Document document = new Document();
document.LoadFromFile(@"E:\Work\Documents\WordDocuments\Humor Them.docx");
//Get Paragraph
Section s = document.Sections[0];
Paragraph p = s.Paragraphs[1];
//Set Font Style and Size
ParagraphStyle style = new ParagraphStyle(document);
style.Name = "FontStyle";
style.CharacterFormat.FontName = "Century Gothic";
style.CharacterFormat.FontSize = 20;
document.Styles.Add(style);
p.ApplyStyle(style.Name);
//Save and Launch
document.SaveToFile("font.docx", FileFormat.Docx2010);
System.Diagnostics.Process.Start("font.docx");
}
}
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace WordImage
Friend Class ImageinWord
Shared Sub Main(ByVal args() As String)
'Load Document
Dim document As New Document()
document.LoadFromFile("E:\Work\Documents\WordDocuments\Humor Them.docx")
'Get Paragraph
Dim s As Section = document.Sections(0)
Dim p As Paragraph = s.Paragraphs(1)
'Set Font Style and Size
Dim style As New ParagraphStyle(document)
style.Name = "FontStyle"
style.CharacterFormat.FontName = "Century Gothic"
style.CharacterFormat.FontSize = 20
document.Styles.Add(style)
p.ApplyStyle(style.Name)
'Save and Launch
document.SaveToFile("font.docx", FileFormat.Docx2010)
System.Diagnostics.Process.Start("font.docx")
End Sub
End Class
End Namespace
Spire.Doc是一個專業(yè)的Word組件,可用于生成、加載、編寫、編輯和保存.NET、Silverlight和WPF的Word文檔。
以上便是如何在C#, VB.NET中設(shè)置Word字體的教程,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn