We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem in Aspose.cells Ole Embedded Object

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)

{

OleObjects oles = worksheet.OleObjects;

for(int i = 0; i<oles.Count; i++)

{

OleObject ole = oles[i];

string filename = @"c:\testAsposeCells" + i ".";

switch(ole.FileType)

{

case OleFileType.Doc:

filename += "doc";

break;

case OleFileType.Xls:

filename += ".xls";

break;

etc...........

}

FileStream file = File.Create(filename);

byte[] data = ole.ObjectData;

file.Write(data,0,data.Length);

}

}

Thanks

Hi,

Could you post your template file here, we will check it soon.

Thank you.

I am attaching the template excel file. The code finds the ole embedded object and creates a excel file for the object, but the excel file is empty.

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.

Thanks

Hi,

Thanks for providing us the template excel file.

We found the issue after an initial test, we will figure it out soon.

Thank you.

Hi,

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();
}
}

Hi,

I couldn't find the oleBook.Worksheets.IsHidden property. So I did this

foreach (Worksheet sheet in oleBook.Worksheets)

{

sheet.IsVisible = true;

}

It doesnot work. when debugging i found the sheet.IsVisible property already true.

Thanks

Hi,

Sorry for your inconvenience.

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.

Thank you.

Hi,

Please try the attached version, Worksheets.IsHidden attribute is publicly available now.

Thank you.

Hi,

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)

{

filenum += 1;

if (shape.ToString().Contains("OleObjectFrame"))

{

string fileName = @"C:\temp\testAsposeSlides" + filenum + ".";

OleObjectFrame oleOF = shape as OleObjectFrame;

switch (oleOF.ObjectType)

{

case OleObjectType.PowerPointPresentation:

fileName += "ppt";

break;

case OleObjectType.MicrosoftExcel:

fileName += "xls";

break;

case OleObjectType.MicrosoftWordTable:

fileName += "doc";

break;

default:

break;

}

FileStream fstr = new FileStream(fileName, FileMode.Create, FileAccess.Write);

byte[] buf = oleOF.ObjectData;

fstr.Write(buf, 0, buf.Length);

fstr.Flush();

fstr.Close();

}

}

}

Thanks

Hi,

Thanks for your inquiry.

Well, since your issue is related to Aspose.Slides, so you 'd better post a query/issue (with all the details) to Aspose.Slides forum: http://www.aspose.com/community/forums/aspose.slides-for-.net-java-reporting-services-and-jasperreports/109/showforum.aspx One of our Aspose.Slides developer will help you soon.

Thank you.