How can i convert an Embedded OLE Excel 97-2003 To Excel 2007

Hi,

I try to convert embedded Excel-OleObjectFrames from 97-2003 to 2007-formatting.
After setting ‘oof.ObjectData’ to the new Excel-BIN the ObjectData-value is null.

What I’m doing wrong ?

My Code:

foreach (Slide item in p.Slides )
{
foreach (Shape s in item.Shapes )
{

if (s.GetType().Name == “OleObjectFrame”)
{
OleObjectFrame oof = (OleObjectFrame)s;
Workbook w;

using (System.IO.MemoryStream msln = new System.IO.MemoryStream(oof.ObjectData))
{
w = new Workbook(msln);
using (System.IO.MemoryStream msout = new System.IO.MemoryStream())
{
oof.ObjectProgId = “Excel.Sheet.12”;
SaveOptions so = new Aspose.Cells.XlsSaveOptions();
so.SaveFormat = SaveFormat.Xlsx;
w.Save(msout, so);
oof.ObjectData = msout.ToArray();

}
}

}
}

}

Regards

Guido

Hello Guido,

I have worked with the code snippet shared by you and have modified that a bit to copy the memory stream as byte inside oof.ObjecData. I have been able to add the date inside it and hopefully, it will work for you as well. Please share with us, if you may feel any issue while using the code snippet.

foreach (Slide item in pres.Slides)
{
    foreach (Shape s in item.Shapes)
    {
        if (s.GetType().Name == "OleObjectFrame")
        {
            OleObjectFrame oof = (OleObjectFrame)s;
            Workbook w;
            using (System.IO.MemoryStream msln = new System.IO.MemoryStream(oof.ObjectData))
            {
                w = new Workbook(msln);
                using (System.IO.MemoryStream msout = new System.IO.MemoryStream())
                {
                    oof.ObjectProgId = "Excel.Sheet.12";
                    Aspose.Cells.SaveOptions so = new Aspose.Cells.XlsSaveOptions();
                    so.SaveFormat = Aspose.Cells.SaveFormat.Xlsx;
                    w.Save(msout, so);

                    msout.Position = 0;
                    msout.Read(oof.ObjectData, 0, (int)msout.Length);
                }
            }
        }
    }
}

Thanks and Regards,

Hi Mudassir,

it did not work.

oof.ObjectData has the same size as before although the new xlsx file is smaller.

It seems as if the new file is not accepted.

fyi: I use Aspose.Slides.Version 4.4.2.0 and Aspose.Cells Version 5.1.3.4

Thanks for your help.

Greetings,

Guido

Dear Guido,

I have discussed the issue with Aspose.Cells team. Can you place use the following code snippet

Aspose.Cells.OoxmlSaveOptions so = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);

w.Save(msout, so);

in place of following code snippet lines

Aspose.Cells.SaveOptions so = new Aspose.Cells.XlsSaveOptions();
so.SaveFormat = Aspose.Cells. SaveFormat.Xlsx;
w.Save(msout, so);

Hopefully things will work for you this time.

Thanks and Regards,

Hi Mudassir ,

sorry but it does not change anything.

I try it with a Powerpoint 2007 - File.

The Object-Data accept the new Excel-binary but
afterwards the OLE-Object is corrupted.

Regards,

Guido

Dear Guido,

I regret to share that I have not been able to experience the issue corrupted OLE frame and can open that as well in presentation file. It will be really convenient if you may please share the project code along with your source excel file as well. We really like to help you out in your issue.

Thanks and Regards,

Hi Mudassir,

in the appendix you will find my project with my example.

Regards

Guido

Dear Guido,

I am sorry for the delayed response. We are working on the issue specified and investigating it. We will share the response with you ASAP.

Thanks and Regards,

Dear Guido,

I have worked with the code snippet shared by you along with Aspose.Cells team. I am able to generate the new presentation based on the code snippet shared. You have mentioned that Ole Object is corrupted. I have not found Ole Frame to be corrupted using Aspose.Slides for .NET 4.4.2 and Aspose.Cells for .NET 5.1.2. Can you please elaborate the issue in more details as may be I may not be understanding the point you are trying to highlight.

We are sorry for your inconvenience,

Hi Mudassir,

i think ‘corrupted’ ist the wrong word.

I mean the current code has not changed anything because
e.g. the table still open in ‘Compatibility Mode’ (see picture).

That’s the point i’m trying to highlight.

Thanks for your help

Guido

Dear Guido,

I have been able to observe the issue shared by you that the embedded Ole object when opened gets opened in compatibility mode. Our development team is investigating the issue and as soon as some information is shared by them, I will share that with you. I really appreciate your patience for this.

Thanks and Regards,