I am using Aspose.Cells to extract an ole embedded object from a excel file. it does not work when I have a excel file embedded inside another excel file. it works fine when the embedded object is a powerpoint presentation or a word document.
This is my code
Workbook workbook = new Workbook();
workbook.open(path);
foreach(Worksheet worksheet in workbook.Worksheets)
I would like to mention one more thing. When I was trying the Aspose.Slides, I was having the same kind of problem with the powerpoint file also. i.e if I have excel or word document embedded inside a powerpoint file, it extracts the ole object correctly. But if I embed a powerpoint inside a powerpoint then again it does not work.
After checking this issue, we find MS Excel will hide the workbook if you use xls file as ole data in MS Excel,so you have to unhide the workbook before you save it to the disk.Please try following codes with the fix:
Workbook workbook = new Workbook(); workbook.Open(@"F:\FileTemp\Excel_Worksheet1.xls"); OleObjects oles = workbook.Worksheets[0].OleObjects; for (int i = 0; i < oles.Count; i++) { OleObject ole = oles[i]; if (ole.FileType == OleFileType.Xls) { MemoryStream ms = new MemoryStream(); ms.Write(ole.ObjectData, 0, ole.ObjectData.Length); Workbook oleBook = new Workbook(); oleBook.Open(ms); oleBook.Worksheets.IsHidden = false; oleBook.Save(@"F:\FileTemp\Book" + i + ".xls"); } else { FileStream fs = File.Create(@"F:\FileTemp\" + i); fs.Write(ole.ObjectData, 0, ole.ObjectData.Length); fs.Close(); } }
Well, Actually, Worksheets.IsHidden is an internal property and we have not made it publicly available for the users in the previous version attached by Simon. We will soon provide you a version in which you may utilize this property for your need.
Thanks for the new version. This worked. But i have the same kind of problem when working with Aspose.slides. When I try to embed a powerpoint inside a powerpoint file it does not work again. Again it creates the ppt file which is empty. Do we have to do a similar thing as we did for the excel i.e setting the hidden property to false. But i dont know how to implement this in powerpoint. I couldn't find that property. Could you please help me with this.
My code is
Presentation pres = new Presentation(path);
int filenum = 0;
foreach(Slide slide in pres.Slides)
{
foreach (Aspose.Slides.Shape shape in slide.Shapes)