Updating Excel Linking (charts and spreadsheets) in PPT(x) Slide

I have a LARGE (250 slides) PPTX file that has dozens of links to an Excel spreadsheet with 25 worksheets. The spreadsheet changes via Aspose cells manipulation to update external data it has links to. The links the into PPTX were created by copying them from Excel and Paste(special) as link. Also several of the charts are on the same spreadsheet. How can I narrow that down ?

What is the best way to update the linked content in the PPTX ?

I have read dozens of articles (a lot out of date) about manipulating the OLE objects, and I could possibly delete and readd them as embedded spreadsheets, but that seems dirty and I am concerned about file size as our spreadsheet is 25Meg and I don't want to embed several times! I can see the link information with the LinkFilePath property and can manipulate it, but when would it reread the Excel file ?

Any help is greatly appreciated.

Chad

Hi Chad,


Thanks for your interest in Aspose.Slides.

I have worked with the presentation file shared by you and like to share that Aspose.Slides offers to add or update linked ole frames inside it. Please observe and use the following sample code for your kind reference and share with us if I may help you further in this regard.


// replacing link path without changing of object’s type
ole.SetObjectLink(null,Path.GetFullPath(Path.Combine(TestSettings.testDataPath, “pptx\worksheet1.xls”)),null);

// adding substitute image image. This is mandatory operation.
Picture pic = new Picture(pres, oleThumbnail);
pres.Pictures.Add(pic);
ole.PictureId = pic.PictureId;

// replacing link and type of an object
ole.SetObjectLink(“Excel.Sheet.8”,new Guid(“{00020820-0000-0000-C000-000000000046}”),null,Path.GetFullPath(Path.Combine(TestSettings.testDataPath, “pptx\worksheet1.xls”)),null);

ole.PictureId = pic.PictureId;



// creating new linked Ole object
ole = slide.Shapes.AddOleObjectFrame(500,100,500,500,“Excel.Sheet.8”,new Guid(“{00020820-0000-0000-C000-000000000046}”),null,Path.GetFullPath(Path.Combine(TestSettings.testDataPath, “pptx\worksheet2.xls”)),null);
ole.PictureId = pic.PictureId;

Please also visit this documentation link for your kind reference as well.

Many Thanks,

Thanks for the reply.

I've seen these examples in other forums and while they are helpful, they are not enough to complete my project.

1 - Using the pptX command of ole.LinkFilePath = "C:\\cells\\test2.xlsx!sheet2!R1C1:R10C4", I was able to change and save the link successfully. However it did not change until I opened in PowerPoint and refreshed it.

2 - The setting of the PictureID seems to be the key of what is displayed when the pptx is opened. Is this correct ? Is the PowerPoint refresh just updating this picture ? How would create pics for the Excel chart and Excell Cells ?

3 - This seems to be a somewhat common request (to programmatically force a refresh of OLE links). Can you publish a explicit example to do this ? Or if it is not possible, at least state that ?

Thanks

Chad

Hi Chad,

I have observed the points shared by you and like to share that the Ole frame is in disabled form until it is enabled either manually by opening presentation in PowerPoint or enabled using any third party macros that are added in presentation and which enable the ole frames inside presentation automatically when presentation is opened using PowerPoint. This is not an issue with Aspose.Slides. Aspose.Slides but is some thing related to Ole engine. Ole engine display a red text “Object Changed” message as a default for disabled ole frame. This seem odd to many customers and for that Aspose.Slides offers a solution to take the image of excel sheet or chart inside Ole frame using Aspose.Cells and add that as Ole frame image. So, with this even the ole frame will be disabled yet it will display the correct ole frame image in disabled form. This is in fact a work around approach for red “Object Changed” message. Please visit this documentation link for your kind reference. Please also visit this article link for getting the worksheet image using Aspose.Cells and applying that as Aspose.Slides ole frame image.

Many Thanks,