C# 读取PPT幻灯片中的批注内容

 时间:2024-11-22 20:31:14

此经验将介绍C#读取取幻灯片中的批注内容。

工具/原料

Free Spire.Presentation for .NET 3.3 (免费版)

Visual Studio

dll引用

1、在E-iceblue官网或者Nuget网站上下载Free Spire.Presentation for .NET的安装包后,注意在编辑代码时,添加引用Spire.Presentation.dll到程序。dll文件可在安装路径下的Bin文件夹中获取。

C# 读取PPT幻灯片中的批注内容

C#代码示例(供参考)

1、测试文件如下:

C# 读取PPT幻灯片中的批注内容

2、using System;using System.Text;using Spire.Presentation;using System.IO;namespace ExtractTextFromComment_PPT{ class Program { static void Main(string[] args) { //实例化一个Presentation类,并加载文档 Presentation ppt = new Presentation(); ppt.LoadFromFile("sample.pptx"); //创建一个StringBuilder对象 StringBuilder str = new StringBuilder(); //获取第一张幻灯片中的所有批注 Comment[] comments = ppt.Slides[0].Comments; //遍历批注内容 for (int i = 0; i < comments.Length; i++) { str.Append(comments[i].Text + "\r\n"); } //将文本写入TXT File.WriteAllText("TextFromComment.txt", str.ToString()); System.Diagnostics.Process.Start("TextFromComment.txt"); } }}

3、完成代码后,调试运行程序,生成文档,如下是批注读取结果:

C# 读取PPT幻灯片中的批注内容
  • 如何给幻灯片插入批注?
  • 怎么给幻灯片添加批注
  • 办公软件,幻灯片怎么插入批注呢?
  • 如何给PPT添加备注或批注?
  • C# 插入批注到Excel
  • 热门搜索
    怎么消除咬肌 加油英文怎么说 飞科剃须刀怎么样 地包天要怎么矫正 怎么做汉堡 idm怎么用 怎么哭出来 太平公主怎么死的 房屋漏水怎么办 的近义词是什么