Free Support Forum - aspose.com

Read embedded Excel object in PowerPoint causes an exception in .NET

Attempting to read Aspose.Cell for an embedded Excel object in powerpoint read in Aspose.Slides causes the following error.
“This file’s format is not supported or you do not specify a correct format.”

The environment is below.
powerpoint file -> Office 2016 or Office 365
Embedded excel file -> Office 2016 or Office 365
Aspose.Slides -> 18.10
Aspose.Cells -> 18.11

I attach the target file.
new.zip (32.9 KB)

Since the embedded Excel format was able to be read correctly in Office 2010,
The cause of the error seems to be the latest Office file.

Please give me correspondence.

@yuya,

Thanks for your query.

Please share a console application (runnable) with us for our testing where this issue can be observed. We will reproduce the problem and provide our feedback after analysis.

The source is below

try
{
    var slides = new Presentation(pptPath);

    foreach (Slide slide in slides.Slides)
    {
        foreach (Shape shape in slide.Shapes)
        {
            string typeName = shape.GetType().Name;

            switch (typeName)
            {
                case "OleObjectFrame":
                    var oleObj = (OleObjectFrame)shape;
                    if (oleObj.ObjectData != null && oleObj.ObjectProgId.Contains("Excel"))
                    {
	                    MemoryStream byteObj = new MemoryStream(oleObj.ObjectData);

	                    FileFormatInfo fileInfo = FileFormatUtil.DetectFileFormat(byteObj);
	                    if (fileInfo.FileFormatType == FileFormatType.Unknown)
	                    {

	                    }
	                    Workbook wb = new Workbook(byteObj);
                    }

                    break;
                default:
                    break;
            }
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

@yuya,

I have reproduced the error on my end with your source code. Could you please also share the template file for which this error is not produced, so that I can log it in our issue management system for a fix.

This is PPT where no error occurs
ok.zip (32.6 KB)

@yuya,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46461 - Aspose.Cells raises an exception

@yuya,

We evaluated your issue thoroughly. Well, It must be the issue of Aspose.Slides API. Please change your sample code as the following without using Aspose.Cells APIs:
e.g
Sample code:

 var oleObj = (OleObjectFrame)shape;
                                if (oleObj.ObjectData != null && oleObj.ObjectProgId.Contains("Excel"))
                                {
                                    MemoryStream byteObj = new MemoryStream(oleObj.ObjectData);
                                    File.WriteAllBytes(dir + "test.xls", byteObj.ToArray());
                                    //FileFormatInfo fileInfo = FileFormatUtil.DetectFileFormat(byteObj);
                                    //if (fileInfo.FileFormatType == FileFormatType.Unknown)
                                    //{

                                    //}
                                    //Workbook wb = new Workbook(byteObj);
                                }

You will notice that the generated file could not be opened fine in MS Excel too.

Please post your issue in Aspose.Slides forum, one of our fellow colleagues from Aspose.Slides team will help you soon there.

Thank you for confirmation.
Is it a problem with Aspose.Slides?

I also wrote to the Aspose.Slides forum.
If you can cooperate internally also on that side, I will be saved.

@yuya,

Thanks for posting in requested forum.

Please follow up in other thread, we will cooperatively take care of your problem and will keep you updated there.