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

Free Support Forum - aspose.com

Need to insert a Excel object from the file location as a OLE to the PPTX

Hi,


I want to insert an OLE object to the Presentation(pptx) file. And the OLE is a excel(.xlsx) file which is stored in the physical location. Please help me.

Refer the attached image for more details.

Thanks,
Laxmikanta

Hi Laxmikanta,


I have observed the snapshot shared by you and have not been able to figure out that if you are looking for embedded Ole frame or linked Ole frame. In case of PPTX presentation, Aspose.Slides offers to embed xlsx file as Ole frame in PowerPoint presentation. Please visit this documentation link for your kind reference. For PPTX, the options for setting linked Ole frame is not available. However, Aspose.Slides does offer to add excel file as linked Ole frame in case of PPT presentation only. Please, visit this documentation link for your kind reference.

Many Thanks,

Hi Mudassir,


I have used your given code snippet. But not able to generate the presentation with OLE from excel file.
Note: Here the excel file is having only one datasheet no chartsheet, and I want to show only the datasheet no chart required.

Find the output presentation file and the excel file with the attachment.
I need the output should be like the attached “Demo.pptx” file.
The used code is:

//Instantiate PrseetationEx class that represents the PPTX
PresentationEx pres = new PresentationEx();
        //Access the first slide
        SlideEx sld = pres.Slides[0];

        //Load an Excel file to stream
        FileStream fs = new FileStream("d:\\pptx\\Copy of GridCheck.xls", FileMode.Open, FileAccess.Read);
        MemoryStream mstream = new MemoryStream();
        byte[] buf = new byte[4096];

        while (true)
        {
            int bytesRead = fs.Read(buf, 0, buf.Length);
            if (bytesRead <= 0)
                break;
            mstream.Write(buf, 0, bytesRead);
        }

        //Add an Ole Object Frame shape
        OleObjectFrameEx oof = sld.Shapes.AddOleObjectFrame(0, 0, pres.SlideSize.Size.Width, pres.SlideSize.Size.Height, "Excel.Sheet.8", mstream.ToArray());

        //Write the PPTX to disk
        pres.Write("d:\\pptx\\OleEmbed.pptx");</span></font></pre><pre class="code-java" style="padding: 0px; margin-top: 0px; margin-bottom: 0px; overflow: auto; font-family: 'Courier New', Courier, monospace; line-height: 1.3; color: rgb(51, 51, 51); font-size: 13px; background-color: rgb(255, 255, 255);"><br></pre><pre class="code-java" style="padding: 0px; margin-top: 0px; margin-bottom: 0px; overflow: auto; font-family: 'Courier New', Courier, monospace; line-height: 1.3; color: rgb(51, 51, 51); font-size: 13px; background-color: rgb(255, 255, 255);">Thanks,</pre><pre class="code-java" style="padding: 0px; margin-top: 0px; margin-bottom: 0px; overflow: auto; font-family: 'Courier New', Courier, monospace; line-height: 1.3; color: rgb(51, 51, 51); font-size: 13px; background-color: rgb(255, 255, 255);">Laxmikanta</pre></div><div><br></div><div><br></div>

Hi Laxmikanta,


I have observed the sample code and there seem no issue. However, when I have observed the excel file it seems that it is of some older format as compare to MS Excel 97~2003. I have re-saved the excel file to MS Excel 97~2003 format and it worked on my end. The issue is that older format files are not supported. Please try using the attached excel file for your kind reference.

Many Thanks,

Hi Mudassir,


I have tried with your attached excel file but it is having same issue. Kindly send me the sample application, which is working in your end.

Find the attachment of the wrong presentation output.

Thanks,
Laxmikanta

Hi Laxmikanta,


I have opened the shared presentation in PowerPoint 2010 and have been able to open the ole frame without any issue. I used the same sample code shared by you without any change. I just saved your source excel file to xls format using MS Excel. Can you please share the snapshot of the issue along with PowerPoint version with which you are reproducing the issue.

Many Thanks,