Free Support Forum - aspose.com

Link excel file to powerpoint

Hi,

We have seen the threads on OLE and note that it seems only possible to Embed Excel.
Our users have a special case that we think is typical…
They wish to get both files in one download with links intact (enabled).
They wish to edit Excel and see the results in the PowerPoint.
How can we accomplish this with the Aspose API?

Regards

Hi,


I have observed your requirements and like to share that you are probably looking for updating the contents in excel file and want that to get updated in ole frame added in PowerPoint presentation using Aspose.Slides. An issue with ID 3103 has been created in our issue tracking system to investigate the possibility of linked ole frames. I will share the further information with you as soon as the feature is available.

Many Thanks,

Hello Support,

Has there been any progress on linking or embedding with aspose.cells and aspose.slides?

Copying a range of cells and pasting them into PowerPoint is common when using Microsoft Office. I would like to find a way to perform this same action with the aspose API. The current workaround is that we save the excel file to pdf and then create an image of the pdf and place that into the PowerPoint. Unfortunately, this is becoming a problem due to file size and storage requirements.

Very much looking forward to a better solution or other creative ideas (apart from just using the PDF directly, which seems to be against the religion of the users who need to make last minute edits to the PowerPoint).

Thanks in advance!

Jason

Hi Jason,

I like to share that we have added the support for adding the linked ole file in Aspose.Slides generated Ole frame. Please use the following sample code to serve the purpose. The issue SLIDESNET-3103 actually relates to providing support for Linked Ole objects. However, as far as your requirement of adding excel sheet text in Aspose.Slides, I like to share that you will need Aspose.Cells in this along side. You will copy the text using Aspose.Cells and will then paste that in slides using Aspose.Slides inside table or text frame.

public static void AddLinkedOle()
{
String path=@“D:\Aspose Data”;
Presentation pres = new Presentation();
Slide slide = pres.GetSlideByPosition(1);

// adding substitute image image. This is mandatory operation.
Picture pic = new Picture(pres, path+“Tulips.jpg”);
pres.Pictures.Add(pic);
// ole.PictureId = pic.PictureId;

// creating new linked Ole object
OleObjectFrame ole = slide.Shapes.AddOleObjectFrame(500, 100, 500, 500, “Excel.Sheet.8”, new Guid("{00020820-0000-0000-C000-000000000046}"), null,path+ “worksheet2.xls”, null);
ole.PictureId = pic.PictureId;

// replacing link and type of an object
ole.SetObjectLink(“Excel.Sheet.8”, new Guid("{00020820-0000-0000-C000-000000000046}"), null, “worksheet1.xls”, null);
ole.PictureId = pic.PictureId;

// replacing link path without changing of object’s type
ole.SetObjectLink(null, “worksheet1.xls”, null);

pres.Write(path + “LinkOle.ppt”);
}

Many Thanks,

Hello Mudassir,

Thank you for the example. I pasted it into LINQPad and it didn't work. So I updated to Slides 7.4.0 and Cells 7.4.3. Now it works, but I did not like the result. I tried to fix it. Can you help me a bit further, please? I have attached my folder with code and results so you can easily re-create the situation I am seeing or you can just view the PPT files generated.

Here's my code now (but the attached .linq file should open in LINQPad and everything should run instantly if you use the same D:\AsposeOle folder).

void Main()

{

String path=@"D:\AsposeOle\";

String source=path+@"worksheetSource.xlsx";

Presentation pres = new Presentation();

Slide slide = pres.GetSlideByPosition(1);

// adding substitute image image. This is mandatory operation. (seriously? In production, how can I get the image, sized properly, of the original excel result?)

Picture pic = new Picture(pres, path+"Tulips.jpg");

pres.Pictures.Add(pic);

// creating new linked Ole object

OleObjectFrame ole = slide.Shapes.AddOleObjectFrame(500, 100, 500, 500, "Excel.Sheet.8", new Guid("{00020820-0000-0000-C000-000000000046}"), null,source, null);

ole.PictureId = pic.PictureId;

pres.Write(path + "LinkOle1.ppt"); //Works, but the tulips image is shown. User must click update links when file is opened. Even then, the image is too small to read.

// replacing link and type of an object

ole.SetObjectLink("Excel.Sheet.8", new Guid("{00020820-0000-0000-C000-000000000046}"), null, source, null);

ole.PictureId = pic.PictureId;

pres.Write(path + "LinkOle2.ppt"); //Sort of slow. Why is that? Still has image of tulips and after update the data is too small to read.

// replacing link path without changing of object's type

ole.SetObjectLink(null, source, null);

pres.Write(path + "LinkOle3.ppt"); //This works nice and is fast, but I still have to click update and I have the image and it is too small.

}

Hi Jason,


I have observed the sample code shared by you. Unfortunately, I don’t have LINQPad environment available on my end. But I have observed that you are trying to link XLSX file in PPT and using Excel.Sheet.8 as class name. In my observation, you can add XLS file as liked ole frame inside PPT frame and use Excel.Sheet.8 as class name. You need to use class name Excel.Sheet.12 for XLSX presentation and I am hopeful that it will work. Please share, if I may help you further in this regard.

Many Thanks,

Hello Mudassir,

Using Excel.Sheet.12 has no visible effect. The Excel image is the same - tiny and unreadable on the powerpoint slide

Can you open my zip and view the ppt's created by the code?

Where should I ask the question about how to embed the excel sheet into the powerpoint? This link method doesn't seem to be helpful until it can be corrected to use the size of the object that is being attached at 100% scale so that the powerpoint will show the exact same size as is shown in Excel in the same manner as if a user were to do a copy/paste from Excel to Powerpoint.

Thank you,

Jason

Hi Jason,


As far as the issue of small Ole frame is concerned, I like to share that it can be controlled. In the following statement you can sett the the width and height of Ole frame as per your requirement.

.AddOleObjectFrame(500, 100, 500, 500, “Excel.Sheet.8”, new Guid("{00020820-0000-0000-C000-000000000046}"), null,source, null);

You can set the bold value as per your convenience to set the size of Ole frame. You can also embed excel sheets inside presentation. For this, please visit this documentation link. Please share, if I may help you further in this regard.

Many Thanks,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan