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

Free Support Forum - aspose.com

Embedding charts in pptx files

I have followed your example for embedding a chart into a slide which goes something like this:

Bitmap imgChart = book.Worksheets[0].Charts[0].ToImage();
MemoryStream ms = book.SaveToStream();
PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];
int slideWidth = (int)pres.SlideSize.Size.Width;
int slideHeight = (int)pres.SlideSize.Size.Height;
int x = 0;
byte[] chartOleData = new byte[ms.Length];
ms.Position = 0;
ms.Read(chartOleData, 0, chartOleData.Length);
OleObjectFrameEx oof = slide.Shapes.AddOleObjectFrame(x, 0, slideWidth, slideHeight, “Excel.Sheet.8”, chartOleData);
oof.Image = pres.Images.AddImage((System.Drawing.Image)imgChart );

And that does work and does sort of embed a chart into the presentation. However, it doesn’t appear to be a true link. The effect i want to duplicate is the same I get when I copy a chart in excel and paste as a link in a slide. When I do this, I get a chart that is still a chart and not an image. It is editable right inside powerpoint and looks nice when I resize it. Your way of embedding charts seems to attach the xlsx file but shows the chart only as an image.

Is there a way to do a true embed that mimics the Copy/Paste As Link?

Hi,

Thanks for your interest in Aspose.Slides.

Well, what I can understand is that you want to embed an Excel Chart that can be edited inside MS PowerPoint. You can "double click" or "right click -> Convert -> Edit" the OLE Object Frame inside the presentation as created through above code for editing the chart inside MS PowerPoint. The image of the MS Excel Chart is created and placed on the OLE Object Frame just to avoid the "Object Changed" message as explained here. Once you have edited, the image will be no more visible, rather actual chart will be activated.

Thanks and Best Regards

I’m not able to attach my file here but I did attach 3 screenshots showing the difference between copy/“paste as link” of a chart into powerpoint and the oleframe your product supports.

After copy/pasting a chart into powerpoint, the chart is editable and i can change axis values, colors, legend, etc.

The oleframe object IS editable after double clicking it as you’ve said. But it just opens the entire workbook inside powerpoint if i immediately click out of it, what’s shown in powerpoint is the visible cells that were on the workbook when it was opened. It’s almost like a view into the excel sheet and not a real linked chart.

Also, the chart I copied/pasted as link shows in the powerpoints list of “all links” which I can break or update but the oleframe has the entire workbook embedded in it.

Is there any way to duplicate the effect of creating a real link between two office documents without using this ole frame?

OR, what would be almost as good, would be the ability to insert a chart into a powerpoint slide without excel at all. Can I do that?

Hi,

Thanks for your interest in Aspose.Slides.

Well, our current approach for using Charts with data is to create a chart in MS Excel Workbook and futher embed it as OLE Object in MS PowerPoint presentation. Data will be in a separate Excel Sheet and the Chart will be in a separate Excel Sheet of the Excel Workbook. To get the chart displayed after "Double Click", the Excel Sheet with chart needs to be the active sheet. A demo for such MS Excel Chart embedded as OLE Object in a PPTX file is attached as zip. For a conceptual information on this topic, please visit this article.

Please note that, the desired results from the attached demo will be achieved only if used with license of Aspose.Slides for .NET as well as Aspose.Cells for .NET.

Hope this will be helpful.

Thanks and Best Regards