news 2026/3/26 20:12:59

使用C#代码在 PowerPoint 中创建编号或项目符号列表

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
使用C#代码在 PowerPoint 中创建编号或项目符号列表

列表是 PowerPoint 演示文稿中非常实用的工具,可以帮助你将信息清晰、简明地呈现出来。无论是展示关键点、总结思路,还是突出重要内容,合理使用列表都能提升幻灯片的可读性、视觉效果和专业感。在本文中,我们将介绍如何使用Spire.Presentation for .NET在 C# 和 VB.NET 中创建 编号列表 和 项目符号列表。

安装 Spire.Presentation for .NET

首先,需要将Spire.Presentation for .NET包中的 DLL 文件添加到你的 .NET 项目中作为引用。你可以通过下载 DLL 文件,也可以使用 NuGet 进行安装。

PM> Install-Package Spire.Presentation

在 PowerPoint 中用 C# 和 VB.NET 创建编号列表

编号列表是在 PowerPoint 中,每一项前都带有数字或数字序列的列表,通常按顺序排列,从 1 开始依次递增。编号列表常用于展示操作步骤、操作说明、排序信息或任何需要明确顺序的内容。

示例代码如下:

using Spire.Presentation; using Spire.Presentation.Drawing; using System.Drawing; namespace CreateNumberedList { internal class Program { static void Main(string[] args) { // 创建一个演示文稿对象 Presentation presentation = new Presentation(); // 获取第一张幻灯片 ISlide slide = presentation.Slides[0]; // 向幻灯片添加一个形状,并设置形状样式 IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 300, 200)); shape.Fill.FillType = FillFormatType.None; // 无填充 shape.Line.FillType = FillFormatType.None; // 无边框 // 向默认段落添加文本 TextParagraph paragraph = shape.TextFrame.Paragraphs[0]; paragraph.Text = "所需的 Web 开发技能:"; paragraph.Alignment = TextAlignmentType.Left; // 左对齐 paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; // 黑色字体 // 定义列表项 string[] listItems = new string[] { " Command-line Unix", " Vim", " HTML", " CSS", " Python", " JavaScript", " SQL" }; // 创建编号列表 foreach (string item in listItems) { TextParagraph textParagraph = new TextParagraph(); textParagraph.Text = item; 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.BulletArabicPeriod; // 阿拉伯数字加点 shape.TextFrame.Paragraphs.Append(textParagraph); // 添加到形状的文本框中 } // 保存生成的演示文稿 presentation.SaveToFile("NumberedList.pptx", FileFormat.Pptx2013); } } }

在 PowerPoint 中用 C# 和 VB.NET 创建符号项目符号列表

符号项目符号列表是指在 PowerPoint 中,每一项前使用符号而非数字进行标记的列表。它适用于展示无特定顺序的信息要点集合,便于观众快速浏览和理解内容,而不强调顺序关系。

示例代码如下:

using Spire.Presentation; using Spire.Presentation.Drawing; using System.Drawing; namespace 创建符号项目符号列表 { internal class Program { static void Main(string[] args) { // 创建一个 Presentation 对象 Presentation presentation = new Presentation(); // 获取第一张幻灯片 ISlide slide = presentation.Slides[0]; // 在幻灯片上添加一个形状,并设置形状样式 IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 350, 200)); shape.Fill.FillType = FillFormatType.None; // 设置形状填充为空 shape.Line.FillType = FillFormatType.None; // 设置形状边框为空 // 向默认段落添加文本 TextParagraph paragraph = shape.TextFrame.Paragraphs[0]; paragraph.Text = "计算机科学课程:"; paragraph.Alignment = TextAlignmentType.Left; // 左对齐 paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; // 设置字体颜色为黑色 // 定义列表项 string[] listItems = new string[] { " 数据结构", " 算法", " 计算机网络", " 操作系统", " 计算理论", " C语言编程", " 计算机组成与体系结构" }; // 创建符号项目符号列表 foreach (string item in listItems) { TextParagraph textParagraph = new TextParagraph(); textParagraph.Text = item; 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); } // 保存生成的演示文稿 presentation.SaveToFile("符号项目符号列表.pptx", FileFormat.Pptx2013); } } }

在 PowerPoint 中使用 C# 和 VB.NET 创建图片项目符号列表

在 PowerPoint 中,图片项目符号列表用小图标或图片代替传统的符号或数字项目符号。每一项内容都用一张图片来表示,为列表增加了视觉元素。当你希望在列表中加入视觉提示,或者用相关图标或图形表示各项内容时,图片项目符号列表尤其适用。

示例代码如下:

using Spire.Presentation; using Spire.Presentation.Drawing; using System.Drawing; namespace 创建图片项目符号列表 { internal class Program { static void Main(string[] args) { // 创建一个演示文稿对象 Presentation presentation = new Presentation(); // 获取第一张幻灯片 ISlide slide = presentation.Slides[0]; // 在幻灯片上添加一个形状,并设置形状样式 IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 180)); shape.Fill.FillType = FillFormatType.None; // 设置形状填充为空 shape.Line.FillType = FillFormatType.None; // 设置形状边框为空 // 向默认段落添加文本 TextParagraph paragraph = shape.TextFrame.Paragraphs[0]; paragraph.Text = "项目任务待办清单:"; paragraph.Alignment = TextAlignmentType.Left; // 左对齐 paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; // 设置字体颜色为黑色 // 定义列表项 string[] listItems = new string[] { " 确定正在进行的项目和任务", " 为任务分配负责人", " 确定任务的优先级", " 跟踪任务的进展状态", " 完成任务后标记为已完成" }; // 创建图片项目符号列表 foreach (string item in listItems) { TextParagraph textParagraph = new TextParagraph(); textParagraph.Text = item; textParagraph.Alignment = TextAlignmentType.Left; // 左对齐 textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid; textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; // 字体颜色黑色 textParagraph.BulletType = TextBulletType.Picture; // 设置为图片项目符号 // 添加图片作为项目符号 IImageData image = presentation.Images.Append(Image.FromFile("icon.png")); textParagraph.BulletPicture.EmbedImage = image; // 将段落添加到形状的文本框中 shape.TextFrame.Paragraphs.Append(textParagraph); } // 保存生成的演示文稿 presentation.SaveToFile("图片项目符号列表.pptx", FileFormat.Pptx2013); } } }

申请临时许可证

如果你希望删除生成文档中的评估提示,或者解除功能限制,请申请一个为期 30 天的试用许可证。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/3/24 16:19:00

基于SpringBoot的私人西服定制系统毕设

博主介绍:✌ 专注于Java,python,✌关注✌私信我✌具体的问题,我会尽力帮助你。一、研究目的本研究旨在设计并实现一个基于SpringBoot框架的私人西服定制系统。该系统旨在通过整合现代信息技术与个性化定制服务,为用户提供高效、便捷的西服定制…

作者头像 李华
网站建设 2026/3/26 17:58:13

基于SpringBoot的膳食营养健康网站毕设源码

博主介绍:✌ 专注于Java,python,✌关注✌私信我✌具体的问题,我会尽力帮助你。一、研究目的本研究旨在构建一个基于SpringBoot框架的膳食营养健康网站,以实现以下研究目的: 首先,本研究旨在通过整合先进的计算机技术&a…

作者头像 李华
网站建设 2026/3/23 22:25:32

安卓离线打包

UniApp Android 离线打包完整 适用于 UniApp 开发者快速掌握 Android 平台离线打包流程,摆脱 HBuilderX 在线云打包依赖,提升构建效率与安全性。 为什么需要离线打包 对于我个人,如果在Hbuilder云打包一次需要的时间太长而且次数有限&…

作者头像 李华
网站建设 2026/3/20 0:15:23

Spark的大数据电商推荐系统(设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码

Spark的大数据电商推荐系统(设计源文件万字报告讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码适合电商卖家提升用户购物体验!保证提供最优质的服务。提供免费就业指导服务。 技术栈:Spark.Hadoop,mysql,Spring boot.Vue 项…

作者头像 李华
网站建设 2026/3/24 20:12:36

基于TensorFlow的AI原生图像生成应用开发教程

基于TensorFlow的AI原生图像生成应用开发全指南 在当今AI技术蓬勃发展的时代,图像生成已成为最引人注目的应用领域之一。本教程将带领您从零开始,使用TensorFlow框架构建一个完整的AI原生图像生成应用。无论您是刚入门的新手还是有一定经验的开发者,都能通过这篇15000字的详…

作者头像 李华
网站建设 2026/3/22 2:32:56

Flutter for OpenHarmony 实战_飞翔的小鸟游戏物理引擎与管道生成

Flutter for OpenHarmony 实战:飞翔的小鸟游戏物理引擎与管道生成 文章目录 Flutter for OpenHarmony 实战:飞翔的小鸟游戏物理引擎与管道生成前言一、重力物理系统1.1 物理参数1.2 重力应用1.3 跳跃控制 二、管道生成系统2.1 管道数据结构2.2 管道生成2…

作者头像 李华