I develop ASP.NET application with Visual Studio 2005 (.NET Framework 2) I’m use Aspose.Cells 5.3.0.0 and Aspose.Slides 5.5.0.0
I need toaddan Excel worksheetinto a PowerPointfile (only as image or as embedded object + image). I’m attached the input Excel file (demo.xls) and a empty pptx file (demo.pptx).
This is the code that I used:
Dim presDemo As New PresentationEx(“C:\demo.pptx”) Dim wBookDemo As New Workbook(“C:\demo.xls”) Dim msDemo As New MemoryStream Dim objectFrameDemo As OleObjectFrameEx
The issue is the ouput file contais the embedded object, but it’s hidden behind the image with red sentence “EMBEDDED OLE OBJECT” (see attachment wrong.pptx). Also, if I edit the embedded object in pptx file, it becomes very big.
Is there a wayto getan output filelike the one that Iattached (correct.pptx)?
I tried touse the objectSheetRenderfor savean image to usein the OleObjectFrameEx object, but it losesthe shades of thecolorsof the objects containedin theexcel sheet,alsosome informationare not properly aligned and last column is missing (see attachment imgFromSheetRender.emf).
Issue # 1: "Embedded
Ole Object" message is not an issue with Aspose.Slides but behavior of Ole
Frame. The ole frame sets default image showing message, "Embedded Ole
Object" when ole frame is not activated. As soon as the Ole frame is
activated it retains the image of respective excel sheet. Aspose.Slides with
Aspose.Cells facilitates to set the image of respective excel sheet
or chart as ole frame image in deactivated stage. Please check the detailed
code here
and see how ole image can be added as per your requirement.
Issue # 2:
Regarding resizing of excel file while opening as Ole object, please check the
details here
with sample code on how to overcome this issue.
In
case you need any further assistance, please do let us know.
imageStream = New MemoryStream sheetImage = New Rendering.SheetRender(wSheet, imgOption) sheetImage.ToImage(0, imageStream) newObjectFrame.Image = slide.Parent.Images.AddImage(imageStream)
But the image quality is bad, it losesthe shades of thecolorsof the objects containedin theexcel sheet,alsosome informationare not properly aligned and last column is missing. You cas see the differences comparing demo.xls with imgFromSheetRender.emf. I’m need to use the sheet as image and not the chart.
Now,
as your reported issue is related to Aspose.Cells, I have asked my colleague
from Aspose.Cells team to check the issue and share his feedback with you via
this forum thread.
Now it worksmuch better,butthere is stilla issue thatI can’t fix:the last column is missingin the output image and the output image has anA4 portrait format,whilethe one youattachedis landscape and fitted to the dataprinted. To resolve thisI had to addthe statement “wSheet.PageSetup.Orientation=PageOrientationType.Landscape”.Sothe last columnalso appears, but the imageis notadaptedto the printed data:how do Ifit the datato the printed image?
I have attachedthe source codewith the input and output files. In theattached zipI have includedboththe output, portrait andlandscape.
You may use ImageOrPrintOptions.OnlyArea property for your requirement. Setting this property to true will render only data area on the image canvas, and adjust the orientation accordingly. Please have a look at below provided code snippet and attached output file.
VB.NET
Dim book = New Workbook(myDir & “demo.xls”) Dim sheet = book.Worksheets(0) Dim imageOptions = New ImageOrPrintOptions()
imageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf
imageOptions.OnlyArea = True Dim render = New SheetRender(sheet, imageOptions)
render.ToImage(0, myDir & “output.emf”)
Ok,perfect,thank you very much! One lastthing:there is a wayto ensurethat the marginsand the cellswithoutcolorarerenderedtransparent in the worksheet’s output image? PowerPoint renders trasparent, whileAsposerenderswhite.
Currently, it is not possible to render cells without colors as transparent in the Sheet2Image feature. MS-Excel renders such cells as transparent in PowerPoint while Aspose.Cells renders them as white. However, we have logged a New Feature request in our database for this option. We will look into it and implement it if possible. Once, it is implemented or we have some other news for you, we will let you know asap.