PPT中插入 OLE 对象

 时间:2024-10-11 23:42:32

1、下载Spire.Office 3.9.1, 并将其中的Spire.XLS.dll文件和Spire.Presentation.dll文件引用到项目中。

2、将代码放入Visual Studio中:【C#】using System;us坡纠课柩ing System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Spire.Xls;using System.Drawing;using Spire.Presentation;using Spire.Presentation.Drawing;using System.IO;namespace Insert_OLE_to_PPT{ class Program { static void Main(string[] args) { //加载Excel文档 Workbook book = new Workbook(); book.LoadFromFile("Sample.xlsx"); //选择单元格范围并将其保存为图像 Image image = book.Worksheets[0].ToImage(1, 1, 5, 5); //新建一个PowerPoint文档 Presentation ppt = new Presentation(); //插入图像到PowerPoint文档 IImageData oleImage = ppt.Images.Append(image); Rectangle rec = new Rectangle(60, 60, image.Width, image.Height); using (MemoryStream ms = new MemoryStream()) { //将Excel数据保存到流 book.SaveToStream(ms); ms.Position = 0; //根据Excel数据将OLE对象插入到PowerPoint文档 Spire.Presentation.IOleObject oleObject = ppt.Slides[0].Shapes.AppendOleObject("excel", ms.ToArray(), rec); oleObject.SubstituteImagePictureFillFormat.Picture.EmbedImage = oleImage; oleObject.ProgId = "Excel.Sheet.12"; } //保存文档 ppt.SaveToFile("插入OLE.pptx", Spire.Presentation.FileFormat.Pptx2013); } }}

3、调试并运行代码后,生成的文档如下图所示:

PPT中插入 OLE 对象
  • CAD中怎么分解图纸中图块?
  • Excel通过VBA实现全屏显示且隐藏水平滚动条技巧
  • WPS软件文字版怎么按比例裁剪图片?
  • cad中用vba设置字体颜色
  • WPS怎么计算正弦值的反正弦值
  • 热门搜索
    螨虫怎么治 ppt主题怎么设置 微信视频怎么美颜 怎么测骨龄 嘴巴干是怎么回事 酒店入住时间怎么算 皮鞋磨脚后跟怎么办 弱视怎么治疗 个人简历自我评价怎么写 怎么变白皮肤简单有效