Problem in extracting Excel Object from PPT slide

Hi,
I am working on a project that
extracts all the embedded objects from PPT file. I have been able to
extract other objects in correct format. But, unfortunately upon extracting XLS sheet that is embedded in PPT slide, the output file gets corrupted.

I have attached the sample PPT file which contains embedded Excel Sheet.

Here is the code snippet,

Presentation srcPres = new Presentation(fs);
//Output file id

int fid = 0;
for (int i = 1; i <= srcPres.Slides.Count; i++)
{
Slide sld = srcPres.GetSlideByPosition(i);

//Extract all ole objects
foreach (Shape shp in sld.Shapes)
{
// OleObjectFrame oof = shp as OleObjectFrame;
OleObjectFrame oof = shp as OleObjectFrame;
//oof will not be null, if shape is ole object frame
if (oof != null)
{
//Check the class
string objName = oof.ObjectName;
string content = oof.ObjectProgId.ToString();
string type = oof.ObjectType.ToString();

string ext = “”;

if (type == “MicrosoftExcel”)
ext = “.xls”;

else if (objName == “Document”)
ext = “.doc”;
else if (objName == “Acrobat Document”)
ext = “.pdf”;

fout = new FileStream(@“c:\test_extrraction\outOLE” + ext, FileMode.Create, FileAccess.Write);

byte[] buf = oof.ObjectData;
fout.Write(buf, 0, buf.Length);
fout.Flush();
fout.Close();


}

}

}

Regards,
Rjv

Dear Rjv,

Thanks for considering Aspose.Slides.

I will look into it and let you know as soon as possible.

Hello guys,
I am also having this same issue. But it is not only related to the PPT but also related to the msword document. The excel embedded in the word document is extracted but in a corrupted format. The extracted excel is not open by the excel program.

Is this the issue/bug related to the Aspose or we are doing something wrong?

Hope to get some information soon.

Thanks in Advance
Pasa


Dear Pasa,

Are you having a problem extracting MS-Word document out of PPT document, where MS-Word document itself contains Excel object? Or your question is related to Aspose.Words?

In case, it is relating to Aspose.Slides, you should attach the source presentation to look into it and for later case; you should post on Aspose.Words forum, so that Aspose.Words could find this bug and fix it.

Dear Shakeel Faiz,
Thanks for your reply.
I am having this problem for both PPT slide and word document while extracting excel file embedded in them.
I will be posting this same issue in Aspose.Words forum also.

Thanks

Dear Rjv,

I investigated and found out that object is not actually getting corrupted. It is the MS-Excel unable to display it standalone probably, we write it with wrong extension, means it does not have .xls extension.

To see, if object is getting corrupted or not, I read the object from your presentation and added it into new presentation, which is attached namely newTest.ppt. If you double click it; you will see; it opens fine.

Anyway, technical team will further sort out the problem and fix it if there is problem with Aspose.Slides and let you know its findings.

Below is the code, which I used for testing.

C#

//Read the source presentation
Presentation pres = new Presentation(@"c:\source\test.ppt");

//Get OleObject containing worksheet
Slide sld = pres.GetSlideByPosition(1);
OleObjectFrame oof = sld.Shapes[2] as OleObjectFrame;

//Create a new presentation and add the above OLE object there
Presentation newPres = new Presentation();
Slide newSld = newPres.GetSlideByPosition(1);
OleObjectFrame oof2 = newSld.Shapes.AddOleObjectFrame(oof.X,
oof.Y, oof.Width, oof.Height, oof.ObjectClassName, oof.ObjectData);

newPres.Write("c:\\source\\newTest.ppt");

Dear Rjv,

Further investigation revealed that it is not the problem of extension; it is actually the OLE object itself, which is partially present. I have attached test.ppt which works fine, I modified it by the doing the following steps.

Open the test.ppt in MS-PowerPoint, double click the worksheet, click Sheet2, click Sheet1, close the test.ppt and finally press yes on MS-PowerPoint prompt for saving the presentation.

You will see that worksheet written by following code now opens fine in MS-Excel, please see output outSheet.xls

C# Code:

//Read the source presentation
Presentation pres = new Presentation(@"c:\source\test.ppt");

//Get OleObject containing worksheet
Slide sld = pres.GetSlideByPosition(1);
OleObjectFrame oof = sld.Shapes[2] as OleObjectFrame;

//Write the object to file
FileStream fs = new FileStream("c:\\outSheet.xls", FileMode.Create, FileAccess.Write);
fs.Write(oof.ObjectData, 0, oof.ObjectData.Length);
fs.Close();

Dear Shakeel,
Thanks for your investigation. After doing this - double click the worksheet, click Sheet2, click Sheet1, close the test.ppt and finally press yes on MS-PowerPoint prompt for saving the presentation. I can extract Excel Sheet in correct format. But, its totaly strange. Are you guys missing something? It seems upon saving excel sheet, it would be embedded in correct format. So, whats the solution? Please, keep on updating about this as this is totaly strange problem.

Regards,
Rjv


Hello,
I am currently evaluating ASPOSE specifically for extracting embedded objects and I have also hit upon this problem. Has the issue with extracting embedded excel ole objects (from any filetype[word,excel,powerpoing] been cleanly resolved? As far as I can tell under all circumstance, the excel file gets detached in an unusable format (as stated in this thread).

Thanks in advance,

Enrique Benedetti