C# 添加PPT项目编号列表
1、在E-iceblue官网或者Nuget网站上下载Free Spire.Presentation for .NET的安装包后,注意在编辑代八码虚码时,添加引用Spire.Presentation.dll到程序颂叮。dll文件可在安装路径雁信下的Bin文件夹中获取。

1、using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace Bullet1_PPT
{
class Program
{
static void Main(string[] args)
{
//新建Presentation实例并添加一个新的shape
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(100, 100, 300, 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);
}
//保存并打开文档
ppt.SaveToFile("项目编号列表.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("项目编号列表.pptx");
}
}
}
2、代码完成后,调试运行程序,生成文档,如下图:
