@vjlourdu84,
Please note that above mentioned blog is quite old and the approach specified in it is obsolete. There have been many changes in API after 2014 and visit the following link for latest information about Presentation.GetSlideById Method. Furthermore, please note that we don not have a public API which will allow extracting embedded stream but it can be easily achieved using third-party open source library, such as OpenMcdf.
First of all, you need to reference this library. It’s available as NuGet package, and you can add it to your project using Package Manager Console:
Install-Package OpenMcdf or using “Manage Nuget Packages” tool (or just download the library and reference it directly). Then, the following sample code can be used to work with embedded document using Aspose.Cells (if embedded item is Excel object).
In case you encounter any issue, please share the input file, so that we can test the scenario in our environment.
[C#]
public static void ExtractOle()
{
Presentation pres = new Presentation(@"Powerpoint_Excel_Dummy.pptx");
foreach (var slide in pres.Slides)
{
Console.WriteLine("Slide #{0}: {1} shapes", slide.SlideNumber, slide.Shapes.Count());
foreach (var shape in slide.Shapes.OrderBy((s) => s.Name))
{
Console.WriteLine("- {0} - {1}", shape.ToString(), shape.Name);
if (shape is OleObjectFrame)
{
if ("Objekt 3".Equals(shape.Name))
{
OleObjectFrame ole = shape as OleObjectFrame;
if ((ole != null) && ("Worksheet".Equals(ole.ObjectName)))
{
using (MemoryStream memoryStream = new MemoryStream(ole.ObjectData))
{
OpenMcdf.CompoundFile compoundFile = new CompoundFile(memoryStream);
OpenMcdf.CFStream stream = compoundFile.RootStorage.GetStream("Package");
byte[] packageData = stream.GetData();
using (MemoryStream packageDataStream = new MemoryStream(packageData))
{
Workbook wb = new Workbook(packageDataStream);
Worksheet ws = wb.Worksheets[0];
using (MemoryStream msOut = new MemoryStream())
{
wb.Save(msOut, Aspose.Cells.SaveFormat.Xlsx);
}
}
}
}
}
}
}
}
pres.Save(@"Test.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}