Spire.Presentation for .NET 是专业的 PowerPoint组件,开发者可以在 .NET 平台上对 PPT文档进行生成、修改、转换和打印等操作,而无需安装 Microsoft PowerPoint。
这么优秀的国产工具怎能错过呢!想要获取更多福利的朋友咨询在线客服哦~
C#
using Spire.Presentation;using Spire.Presentation.Drawing;using System;using System.Drawing;using System.IO;namespace InsertZip{ class Program { static void Main(string[] args) { //创建一个PPT文档,并获取第一张幻灯片(创建的PPT默认包含一张空白幻灯片) Presentation ppt = new Presentation(); ISlide slide = ppt.Slides[0]; //读取zip文件到byte数组 byte[] data = File.ReadAllBytes("sample.zip"); //在幻灯片中绘制形状,并添加zip文件对象 Rectangle rec = new Rectangle(120, 120, 100, 100); IOleObject ole = slide.Shapes.AppendOleObject("sample.zip", data, rec); ole.ProgId = "Package"; //设置对象封面图片 Image image = Image.FromFile("logo.png"); IImageData oleImage = ppt.Images.Append(image); ole.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage; //保存文档 ppt.SaveToFile("InsertZip.pptx", Spire.Presentation.FileFormat.Pptx2013); System.Diagnostics.Process.Start("InsertZip.pptx"); } }}
VB.NET
Imports Spire.PresentationImports Spire.Presentation.DrawingImports System.DrawingImports System.IONamespace InsertZipClass ProgramPrivate Shared Sub Main(args As String())'创建一个PPT文档,并获取第一张幻灯片(创建的PPT默认包含一张空白幻灯片)Dim ppt As New Presentation()Dim slide As ISlide = ppt.Slides(0)'读取zip文件到byte数组Dim data As Byte() = File.ReadAllBytes("sample.zip")'在幻灯片中绘制形状,并添加zip文件对象Dim rec As New Rectangle(120, 120, 100, 100)Dim ole As IOleObject = slide.Shapes.AppendOleObject("sample.zip", data, rec)ole.ProgId = "Package"'设置对象封面图片Dim image__1 As Image = Image.FromFile("logo.png")Dim oleImage As IImageData = ppt.Images.Append(image__1)ole.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage'保存文档ppt.SaveToFile("InsertZip.pptx", Spire.Presentation.FileFormat.Pptx2013)System.Diagnostics.Process.Start("InsertZip.pptx")End SubEnd ClassEnd Namespace
嵌入效果

还想要更多吗可以点击阅读【2020 · E-iceblue最新资源整合】,查找需要的教程资源。是E-iceblue官方友好合作伙伴,如果您对spire.Presentation感兴趣,可以联系在线客服了解具体授权价格和使用机制。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!