在PowerPoint文档中,我们可以为罗列的多条并列信息添加项目符号或项目编号,使文档更具有条理性和清晰可读性。同时,我们也可以创建多层编号列表,让文档具有层次性。本文将介绍如何使用Spire.Presentation创建编号列表,项目符号列表, 和多层项目编号列表。
创建项目符号列表
C#
//新建Presentation实例并添加一个新的shape
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 200, 150));
shape.Fill.FillType = FillFormatType.None;
//添加第一个段落并设置文字,字体颜色,对齐方式
shape.TextFrame.Text = "销售部工作计划";
shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid;
shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black;
shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
//设置列表方式为符号列表
shape.TextFrame.Paragraphs[0].BulletType = TextBulletType.Symbol;
//添加更多段落并设置符号列表及格式
string[] str = new string[] { "技术支持部工作计划", "开发部工作计划" };
foreach (string txt in str)
{
TextParagraph textParagraph = new TextParagraph();
textParagraph.Text = txt;
textParagraph.Alignment = TextAlignmentType.Left;
textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;
textParagraph.BulletType = TextBulletType.Symbol;
shape.TextFrame.Paragraphs.Append(textParagraph);
}
//保存文档
ppt.SaveToFile( "项目符号列表.pptx", FileFormat.Pptx2013);
VB.NET
'新建Presentation实例并添加一个新的shape Dim ppt As New Presentation() Dim shape As IAutoShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle,New RectangleF(50,70,200,150)) shape.Fill.FillType = FillFormatType.None '添加第一个段落并设置文字,字体颜色,对齐方式
shape.TextFrame.Text = "销售部工作计划"
shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid
shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black
shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left
'设置列表方式为符号列表 shape.TextFrame.Paragraphs(0).BulletType = TextBulletType.Symbol '添加更多段落并设置符号列表及格式
Dim str As String() = New String() {"技术支持部工作计划", "开发部工作计划"}
For Each txt As String In str
Dim textParagraph As New TextParagraph()
textParagraph.Text = txt
textParagraph.Alignment = TextAlignmentType.Left
textParagraph.TextRanges(0).Fill.FillType = FillFormatType.Solid
textParagraph.TextRanges(0).Fill.SolidColor.Color = Color.Black
textParagraph.BulletType = TextBulletType.Symbol
shape.TextFrame.Paragraphs.Append(textParagraph)
Next
'保存文档 ppt.SaveToFile("项目符号列表.pptx",FileFormat.Pptx2013)
创建编号列表
C#
Presentation presentation = new Presentation();IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,new RectangleF(50,70,200,150));shape.Fill.FillType = FillFormatType.None;shape.TextFrame.Text = "销售部工作计划";shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid;shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black;shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;//设置列表方式为编号列表并设置编号样式 shape.TextFrame.Paragraphs[0].BulletType = TextBulletType.Numbered;shape.TextFrame.Paragraphs[0].BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;string[] str = new string[]{"技术支持部工作计划","开发部工作计划"};foreach (string txt in str){TextParagraph textParagraph = new TextParagraph();textParagraph.Text = txt;textParagraph.Alignment = TextAlignmentType.Left;textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;textParagraph.BulletType = TextBulletType.Numbered;textParagraph.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;shape.TextFrame.Paragraphs.Append(textParagraph);}//save the document presentation.SaveToFile("编号列表.pptx",FileFormat.Pptx2010);
VB.NET
Dim presentation As New Presentation() Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle,New RectangleF(50,70,200,150)) shape.Fill.FillType = FillFormatType.None shape.TextFrame.Text = "销售部工作计划" shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left '设置列表方式为编号列表并设置编号样式
shape.TextFrame.Paragraphs(0).BulletType = TextBulletType.Numbered
shape.TextFrame.Paragraphs(0).BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod
Dim str As String() = New String() {"技术支持部工作计划", "开发部工作计划"}
For Each txt As String In str
Dim textParagraph As New TextParagraph()
textParagraph.Text = txt
textParagraph.Alignment = TextAlignmentType.Left
textParagraph.TextRanges(0).Fill.FillType = FillFormatType.Solid
textParagraph.TextRanges(0).Fill.SolidColor.Color = Color.Black
textParagraph.BulletType = TextBulletType.Numbered
textParagraph.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod
shape.TextFrame.Paragraphs.Append(textParagraph)
Next
'save the document presentation.SaveToFile("编号列表.pptx",FileFormat.Pptx2010)
创建多层编号列表
C#
Presentation ppt = new Presentation();IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,new RectangleF(50,70,200,150));shape.Fill.FillType = FillFormatType.None;//添加第一层列表第一段数据 shape.TextFrame.Text = "销售部工作计划";shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid;shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black;shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;//设置列表方式为编号列表并设置编号样式 shape.TextFrame.Paragraphs[0].BulletType = TextBulletType.Numbered;shape.TextFrame.Paragraphs[0].BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;//添加第二层列表的数据 TextParagraph textParagraph = new TextParagraph();textParagraph.Text = "月计划";textParagraph.Alignment = TextAlignmentType.Left;textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;shape.TextFrame.Paragraphs.Append(textParagraph);shape.TextFrame.Paragraphs[1].Alignment = TextAlignmentType.Left;//设置列表方式为编号列表并设置编号样式 shape.TextFrame.Paragraphs[1].BulletType = TextBulletType.Numbered;shape.TextFrame.Paragraphs[1].BulletStyle = NumberedBulletStyle.BulletCircleNumDBPlain;//设置第二层列表的Margin 以产生层次感 shape.TextFrame.Paragraphs[1].LeftMargin = 30;//添加第一层列表第二段数据 TextParagraph textParagraph2 = new TextParagraph();textParagraph2.Text = "技术支持部工作计划";textParagraph2.Alignment = TextAlignmentType.Left;textParagraph2.TextRanges[0].Fill.FillType = FillFormatType.Solid;textParagraph2.TextRanges[0].Fill.SolidColor.Color = Color.Black;//设置列表方式为编号列表为第二个并设置编号样式 textParagraph2.BulletType = TextBulletType.Numbered;textParagraph2.BulletNumber = 2;textParagraph2.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod;shape.TextFrame.Paragraphs.Append(textParagraph2);//保存文档 ppt.SaveToFile("多层编号列表.pptx",FileFormat.Pptx2013);
VB.NET
Dim ppt As New Presentation() Dim shape As IAutoShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle,New RectangleF(50,70,200,150)) shape.Fill.FillType = FillFormatType.None '添加第一层列表第一段数据
shape.TextFrame.Text = "销售部工作计划"
shape.TextFrame.TextRange.Fill.FillType = FillFormatType.Solid
shape.TextFrame.TextRange.Fill.SolidColor.Color = Color.Black
shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left
'设置列表方式为编号列表并设置编号样式 shape.TextFrame.Paragraphs(0).BulletType = TextBulletType.Numbered shape.TextFrame.Paragraphs(0).BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod '添加第二层列表的数据
Dim textParagraph As New TextParagraph()
textParagraph.Text = "月计划"
textParagraph.Alignment = TextAlignmentType.Left
textParagraph.TextRanges(0).Fill.FillType = FillFormatType.Solid
textParagraph.TextRanges(0).Fill.SolidColor.Color = Color.Black
shape.TextFrame.Paragraphs.Append(textParagraph)
shape.TextFrame.Paragraphs(1).Alignment = TextAlignmentType.Left
'设置列表方式为编号列表并设置编号样式 shape.TextFrame.Paragraphs(1).BulletType = TextBulletType.Numbered shape.TextFrame.Paragraphs(1).BulletStyle = NumberedBulletStyle.BulletCircleNumDBPlain '设置第二层列表的Margin 以产生层次感
shape.TextFrame.Paragraphs(1).LeftMargin = 30
'添加第一层列表第二段数据 Dim textParagraph2 As New TextParagraph() textParagraph2.Text = "技术支持部工作计划" textParagraph2.Alignment = TextAlignmentType.Left textParagraph2.TextRanges(0).Fill.FillType = FillFormatType.Solid textParagraph2.TextRanges(0).Fill.SolidColor.Color = Color.Black '设置列表方式为编号列表为第二个并设置编号样式
textParagraph2.BulletType = TextBulletType.Numbered
textParagraph2.BulletNumber = 2
textParagraph2.BulletStyle = NumberedBulletStyle.BulletRomanLCPeriod
shape.TextFrame.Paragraphs.Append(textParagraph2)
'保存文档 ppt.SaveToFile("多层编号列表.pptx",FileFormat.Pptx2013)