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

Free Support Forum - aspose.com

Embedding Excel Chart in ppt slide creates corrupt Ole excel object

Hi,

After an update to the latest aspose.slides the following code has been producing Ole objects that are corrupt and cannot be opened / modified within the power point presentation.

I do not remember which version of aspose.slides i was using before unfortunately.

Do i need to meet new requirements when exporting an excel ole object for it to be valid in a ppt?

Code Example:


Worksheet ws = wb.Worksheets[“ppt”];

Slide replaceSlide = pres.GetSlideById(someddlvalue);
Shape replaceShape = FindShape(replaceSlide.Shapes, someddlvalue);
Chart chart = ws.Charts[someddlvalue];

//Copy chart to a new workbook so i can set the position appropriately for the ole object to appear clean:
Workbook wbObj = new Workbook();
wbObj.Worksheets.Add();
Worksheet wsObj = wbObj.Worksheets[0];
wsObj.Name = “ppt”;
wsObj.Shapes.AddCopy(chart.ChartObject, 0, 0, 0, 0);
wsObj.Shapes[0].Width = replaceShape.Width;
wsObj.Shapes[0].Height = replaceShape.Height;

//Export img for the obj and add it to the presentation:
ImageOrPrintOptions imgOpts = new ImageOrPrintOptions();
imgOpts.ImageFormat = ImageFormat.Png;
imgOpts.SaveFormat = SaveFormat.Excel97To2003;
Bitmap imgChart = new Bitmap(wsObj.Charts[0].ToImage(imgOpts));
Aspose.Slides.Picture pptImg = new Aspose.Slides.Picture(pres, imgChart);
int imgIndex = pres.Pictures.Add(pptImg);

//Add an OleObject to the pres with the above image:
MemoryStream wbStream = wbObj.SaveToStream();
byte[] chartOleData = new byte[wbStream.Length];
wbStream.Position = 0;
wbStream.Read(chartOleData, 0, chartOleData.Length);
Aspose.Slides.OleObjectFrame oof = pres.Slides[0].Shapes.AddOleObjectFrame(replaceShape.X, replaceShape.Y, replaceShape.Width, replaceShape.Height, “Excel.Sheet.” + wbObj.Worksheets[“ppt”].Index.ToString(), chartOleData);
oof.PictureId = imgIndex;

pres.Write(somelocation);

Method used for shapes:
private Shape FindShape(Shapes shapes, int shapeId)
{
foreach (Shape shape in shapes)
{
if (shape.ShapeId == shapeId)
{
return shape;
}
}
return null;
}

Any help is appreciated.

Thanks,

Craig W.

Reverting back to version 5.6.0 for .net 3.5 seems to have fixed the issue with chart corruption in the ppt slide.

Hi Craig,


Thanks for your interest in Aspose.Slides.

I like to share that the issue shared by you has already been added in our issue tracking system with ID SLIDESNET-33214. This thread has been linked with the same issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,