翻譯|使用教程|編輯:李顯亮|2021-04-19 11:40:01.467|閱讀 303 次
概述:本文向您展示如何使用帶有C#和VB.NET的Spire.Doc在Word文檔中將ASCII字符(特殊符號(hào))設(shè)置為項(xiàng)目符號(hào)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一個(gè)專業(yè)的Word .NET庫(kù),設(shè)計(jì)用于幫助開發(fā)人員高效地開發(fā)創(chuàng)建、閱讀、編寫、轉(zhuǎn)換和打印任何來自.NET( C#, VB.NET, ASP.NET)平臺(tái)的Word文檔文件的功能。
本文向您展示如何使用帶有C#和VB.NET的Spire.Doc在Word文檔中將ASCII字符(特殊符號(hào))設(shè)置為項(xiàng)目符號(hào)。
點(diǎn)擊下載Spire.Doc for .NET最新版
C#
using Spire.Doc;
using Spire.Doc.Documents;
namespace SetBulletCharacter
{
class Program
{
static void Main(string[] args)
{
//Create a Document object and add a section
Document doc = new Document();
Section section = doc.AddSection();
//Create four list styles based on different ASCII characters
ListStyle listStyle1 = new ListStyle(doc, ListType.Bulleted);
listStyle1.Name = "liststyle";
listStyle1.Levels[0].BulletCharacter = "\x006e";
listStyle1.Levels[0].CharacterFormat.FontName = "Wingdings";
doc.ListStyles.Add(listStyle1);
ListStyle listStyle2 = new ListStyle(doc, ListType.Bulleted);
listStyle2.Name = "liststyle2";
listStyle2.Levels[0].BulletCharacter = "\x0075";
listStyle2.Levels[0].CharacterFormat.FontName = "Wingdings";
doc.ListStyles.Add(listStyle2);
ListStyle listStyle3 = new ListStyle(doc, ListType.Bulleted);
listStyle3.Name = "liststyle3";
listStyle3.Levels[0].BulletCharacter = "\x00b2";
listStyle3.Levels[0].CharacterFormat.FontName = "Wingdings";
doc.ListStyles.Add(listStyle3);
ListStyle listStyle4 = new ListStyle(doc, ListType.Bulleted);
listStyle4.Name = "liststyle4";
listStyle4.Levels[0].BulletCharacter = "\x00d8";
listStyle4.Levels[0].CharacterFormat.FontName = "Wingdings";
doc.ListStyles.Add(listStyle4);
//Add four paragraphs and apply list style separately
Paragraph p1 = section.Body.AddParagraph();
p1.AppendText("Spire.Doc for .NET");
p1.ListFormat.ApplyStyle(listStyle1.Name);
Paragraph p2 = section.Body.AddParagraph();
p2.AppendText("Spire.PDF for .NET");
p2.ListFormat.ApplyStyle(listStyle2.Name);
Paragraph p3 = section.Body.AddParagraph();
p3.AppendText("Spire.XLS for .NET");
p3.ListFormat.ApplyStyle(listStyle3.Name);
Paragraph p4 = section.Body.AddParagraph();
p4.AppendText("Spire.Presentation for .NET");
p4.ListFormat.ApplyStyle(listStyle4.Name);
//Save to file
doc.SaveToFile("output.docx", FileFormat.Docx2013);
}
}
}
VB.NET
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace SetBulletCharacter
Class Program
Shared Sub Main(ByVal args() As String)
'Create a Document object and add a section
Document doc = New Document()
Dim section As Section = doc.AddSection()
'Create four list styles based on different ASCII characters
Dim listStyle1 As ListStyle = New ListStyle(doc, ListType.Bulleted)
listStyle1.Name = "liststyle"
listStyle1.Levels(0).BulletCharacter = "\x006e"
listStyle1.Levels(0).CharacterFormat.FontName = "Wingdings"
doc.ListStyles.Add(listStyle1)
Dim listStyle2 As ListStyle = New ListStyle(doc, ListType.Bulleted)
listStyle2.Name = "liststyle2"
listStyle2.Levels(0).BulletCharacter = "\x0075"
listStyle2.Levels(0).CharacterFormat.FontName = "Wingdings"
doc.ListStyles.Add(listStyle2)
Dim listStyle3 As ListStyle = New ListStyle(doc, ListType.Bulleted)
listStyle3.Name = "liststyle3"
listStyle3.Levels(0).BulletCharacter = "\x00b2"
listStyle3.Levels(0).CharacterFormat.FontName = "Wingdings"
doc.ListStyles.Add(listStyle3)
Dim listStyle4 As ListStyle = New ListStyle(doc, ListType.Bulleted)
listStyle4.Name = "liststyle4"
listStyle4.Levels(0).BulletCharacter = "\x00d8"
listStyle4.Levels(0).CharacterFormat.FontName = "Wingdings"
doc.ListStyles.Add(listStyle4)
'Add four paragraphs and apply list style separately
Dim p1 As Paragraph = section.Body.AddParagraph()
p1.AppendText("Spire.Doc for .NET")
p1.ListFormat.ApplyStyle(listStyle1.Name)
Dim p2 As Paragraph = section.Body.AddParagraph()
p2.AppendText("Spire.PDF for .NET")
p2.ListFormat.ApplyStyle(listStyle2.Name)
Dim p3 As Paragraph = section.Body.AddParagraph()
p3.AppendText("Spire.XLS for .NET")
p3.ListFormat.ApplyStyle(listStyle3.Name)
Dim p4 As Paragraph = section.Body.AddParagraph()
p4.AppendText("Spire.Presentation for .NET")
p4.ListFormat.ApplyStyle(listStyle4.Name)
'Save to file
doc.SaveToFile("output.docx", FileFormat.Docx2013)
End Sub
End Class
End Namespace
效果圖:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn