在最新发布的Spire.Presentation v4.11中新提供新方法来替换PowerPoint文档中的文本,我们一起来看看吧。
Spire.Presentation for .NET是专业的 PowerPoint组件,使用该组件,开发者可以在 .NET 平台上对 PowerPoint文档进行生成、读取、写入、修改、转换和打印等操作。
Spire.Presentation for .NET支持 PPT、PPS、PPTX、PPSX 格式的 PowerPoint档,支持的主要功能有写入文本、插入图片、添加图形、表格、动画效果、音频和视频等元素到幻灯片。Spire.Presentation也支持将幻灯片转换为 EMF、JPG、TIFF、PDF、XPS、SVG、HTML 格式文件。
推荐阅读:
在下面的示例中,我们将向您展示如何使用上述方法替换PowerPoint文档中的文本。
仅替换第一次出现的搜索文本
using Spire.Presentation;namespace ReplaceFirstText{ class Program { static void Main(string[] args) { //Create a Presentation instance Presentation ppt = new Presentation(); //Load the PowerPoint document ppt.LoadFromFile("Input.pptx"); //Get the first slide ISlide slide = ppt.Slides[0]; //Replace the first occurrence of “Spire.Presentation” with “New Text” by using ReplaceFirstText method slide.ReplaceFirstText("Spire.Presentation", "New Text", false); //Save the resultant document ppt.SaveToFile("RplaceFirstText.pptx", FileFormat.Pptx2013); } }}
12月优惠进行时,Spire系列产品开发订阅版优惠¥7170 起,想买正版授权的朋友赶快咨询在线客服吧!
替换所有出现的搜索文字
using Spire.Presentation;namespace ReplaceAllText{ class Program { static void Main(string[] args) { //Create a Presentation instance Presentation ppt = new Presentation(); //Load the PowerPoint document ppt.LoadFromFile("Input.pptx"); //Get the first slide ISlide slide = ppt.Slides[0]; //Replace all the occurrences of “Spire.Presentation” with “New Text” by using ReplaceAllText method slide.ReplaceAllText("Spire.Presentation", "New Text", false); //Save the resultant document ppt.SaveToFile("RplaceAllText.pptx", FileFormat.Pptx2013); } }}
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!