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

Free Support Forum - aspose.com

Update OleObjectFrameEx objectData failed using InsertClone

Hi, I am trying to clone a new slide, and update objectData of the OleObjectFrameEx shape in the new slide without changing the original slide.

But when I open the saved presentation, I found the data in the original slide had been changed too.
Please help, following is code, and the original presentation is attached.

var present = new PresentationEx(@“C:\projects\test.pptx”);
var shape = (OleObjectFrameEx)present.Slides[0].Shapes[0];

using (Stream stream = new MemoryStream(shape.ObjectData))
{
Workbook wb = new Workbook(stream);
wb.Worksheets[1].Cells[1, 1].PutValue(0.1);
wb.Worksheets[1].Cells[2, 1].PutValue(0.2);

Bitmap imgChart = wb.Worksheets[0].Charts[0].ToImage();

var newImage = present.Slides[0].Parent.Images.AddImage(imgChart);

shape.Image = newImage;
using (MemoryStream msout = wb.SaveToStream())
{
msout.Position = 0;
shape.ObjectData = msout.ToArray();
}
}


present.Slides.InsertClone(1,present.Slides[0]);
shape = (OleObjectFrameEx) present.Slides[1].Shapes[0];
using (Stream stream = new MemoryStream(shape.ObjectData))
{
Workbook wb = new Workbook(stream);
wb.Worksheets[1].Cells[1, 1].PutValue(0.6);
wb.Worksheets[1].Cells[2, 1].PutValue(0.7);

Bitmap imgChart = wb.Worksheets[0].Charts[0].ToImage();

var newImage = present.Slides[1].Parent.Images.AddImage(imgChart);

shape.Image = newImage;
using (MemoryStream msout = wb.SaveToStream())
{
msout.Position = 0;
shape.ObjectData = msout.ToArray();
}
}
present.Save(@“C:\test001.pptx”,SaveFormat.Pptx);


Anybody help me ? Thanks

Hi Katze,


I have worked with the sample code shared using the template presentation and have been able to reproduce the issue specified. An issue with ID SLIDESNET-33810 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,
I encountered the same issue.

Everything works fine before the PPT is saved to disk. I debug the presentation object in memory and the data are all correct. Then I saved it to disk and open the file, I can see that every slide displays correct data, but when I double click one of these slide, the other cloned slides was changed and these slides display the same thing.

I am quite struggle to this. Please advice.
Any help will be appreciated!

hi Mudassir,


Is it possible to provide a temp solution for this?

Hi Wolf,


I would request you to please share the sample presentation along with code snippet to reproduce the issue on my end and observe whether it is same issue as shared SLIDESNET-33810. Please also share the generated presentation for reference as well.

Many Thanks,

Hi Wolf,


We have investigated the issue shared. Actually, you need to remove the respective categories data as well. Please use the following sample code to serve the purpose.


public static void TestCategoryRemove()
{
var fis = new FileStream(“D:\Aspose Data\exampleBefore2.pptx”, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(fis);
fis.Close();

foreach (Aspose.Slides.Pptx.SlideEx slide in pres.Slides)
{
foreach (Aspose.Slides.Pptx.ShapeEx aShape in slide.Shapes)
{
if (aShape.AlternativeText.Replace("\n", “”).Replace("\r", “”).Trim().ToLower().Contains(“ppt.slide.”))
{
switch (aShape.GetType().FullName)
{
case “Aspose.Slides.Pptx.PictureFrameEx”:
break;
case “Aspose.Slides.Pptx.ChartEx”:
Aspose.Slides.Pptx.ChartEx chart = (Aspose.Slides.Pptx.ChartEx)aShape;

int defaultWorksheetIndex = 0;
Aspose.Slides.Pptx.Charts.ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

fact.GetCell(defaultWorksheetIndex, 1, 0, “Testing Category 1”);
fact.GetCell(defaultWorksheetIndex, 2, 0, “Testing Category 2”);
fact.GetCell(defaultWorksheetIndex, 3, 0, “Testing Category 3”);
fact.GetCell(defaultWorksheetIndex, 4, 0, “Testing Category 4”);
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 5, 0, “Testing Category 5”));
chart.ChartData.Categories.RemoveAt(5);
fact.GetCell(defaultWorksheetIndex, 6, 0, String.Empty);
chart.DisplayBlanksAs = DisplayBlanksAsTypeEx.Gap;




Aspose.Slides.Pptx.Charts.ChartSeriesEx series = chart.ChartData.Series[0];

series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, 5));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 4));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 3));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 4, 1, 2));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 5, 1, 1));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 6, 1, String.Empty));

series = chart.ChartData.Series[1];

series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 2, 15));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 2, 14));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 2, 13));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 4, 2, 12));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 5, 2, 1));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 6, 2, String.Empty));
fact.GetCell(defaultWorksheetIndex, 6, 3, String.Empty);
chart.ChartData.Series.RemoveAt(2);

break;
case “Aspose.Slides.Pptx.TableEx”:
break;
case “Aspose.Slides.Pptx.AutoShapeEx”:
break;
}
}
}
}

pres.Write(“D:\Aspose Data\exampleAfter.pptx”);
}


Many Thanks,

The issues you have found earlier (filed as SLIDESNET-33810) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan