We have been successfully using Aspose slides and Cells in production for 2 years. I am having difficulty transitioning to use the newer pptx namespace (with Office 2007).
I am using Aspose.Cells.dll (v 4.8.2) and Aspose.Slides.dll (v 4.1.0).
Basically, we have an existing presentation template with embedded worksheets and charts. We open the template, processes the slides and save to a new presentation.
Each slide is checked for OleObjectFrames that hold xls (now xlsx) worksheets. The worksheet is then opened, edited and saved back into the cloned slide.
Currently I am focusing on 2 issues.
1) I have previously found the worksheet I want to work with by using the “Alternate Text” of the shape (OLEObjectFrame).
Slide sld= pres.Slides[1];
OleObjectFrame oof = (OleObjectFrame)sld.FindShape(identifyingAltText);
The corresponding method in the pptx namespace does not find the shape.
SlideEx sld= presEx.Slides[1];
OleObjectFrameEx oof = (OleObjectFrameEx)sld.FindShapeByAltText(identifyingAltText);
2) I can reference the OleObjectFrame by Shapes[index], open the worksheet, edit it, save it back to the OleObjectFrame, and save the presentationex.
But when I try to open the worksheet in the saved presentation, in PowerPoint, I get the following error:
"The server application, source file, or item can’t be found, or returned an unknown error. You may need to reinstall the server application."
Here is some example code:
static void ChangeOneSlide(PresentationEx presEx, string OutTemplateName)
{
SlideEx sld = presEx.Slides[1];
string identifyingText = “PlanHealthSummary”;
// OleObjectFrameEx oof = (OleObjectFrameEx)sld.FindShapeByAltText(identifyingText);
OleObjectFrameEx oof = (OleObjectFrameEx)sld.Shapes[0];
Workbook w = new Workbook();
MemoryStream msIn = new MemoryStream(oof.ObjectData);
w.Open(msIn);
Worksheet ws = w.Worksheets[0];
ws.Cells[1, 1].PutValue(“Hey There!”);
MemoryStream msOut = w.SaveToStream();
//OleObjectFrameEx objectFrame = (OleObjectFrameEx)sld.FindShapeByAltText(identifyingText);
OleObjectFrameEx objectFrame = (OleObjectFrameEx)sld.Shapes[0];
objectFrame.ObjectData = msOut.ToArray();
PresentationEx.Write(OutTemplateName);
}
(If I just clone the xlsx worksheet, and don’t open, edit and save it, there is no problem in the resulting presentation.)
Thank you for any help or advice you can give us.
ScottVP
Hi Scott,
Please use the following code instead.
static void ChangeOneSlide(PresentationEx presEx, string OutTemplateName)
{
SlideEx sld = presEx.Slides[1];
OleObjectFrameEx oof = (OleObjectFrameEx)sld.Shapes[0];
Workbook w = new Workbook();
MemoryStream msIn = new MemoryStream(oof.ObjectData);
w.Open(msIn);
Worksheet ws = w.Worksheets[0];
ws.Cells[1, 1].PutValue("Hey There!");
MemoryStream msout = new MemoryStream();
w.Save(msout, FileFormatType.Excel2007Xlsx);
OleObjectFrameEx objectFrame = (OleObjectFrameEx)sld.Shapes[0];
objectFrame.ObjectData = msout.ToArray();
presEx.Write(OutTemplateName);
}
Thank you Muhammad for the rapid and very helpful reply. That fixed my second question.
Any thoughts on accessing an OLEObjectFrame using the Alternate text?
(I previously attached a pptx file that had an OLEObjectFrame with an alternate text assigned.)
Thanks again,
Scott
Hi Scott,
An issue with issue id 13319 has been created to fix the issue for alternative text on our Issue Tracking System. This thread has been associated with this issue, so you will get an automated notification as soon as this issue is fixed.
Muhammad, Thank you for your help on my previous question.
I have an additional question. The embedded spreadsheet is not retaining the formatting when it is opened in the new presentation. I am attaching the template pptx that I am using. The code is below. Thank you for any help that you can give me.
string templateFileName = “NewTestTemplate3.pptx”;
string EmptyTemplateName =“Empty.pptx”;
string outFileName = “out.pptx”;
PresentationEx srcPres = new PresentationEx(templateFileName);
SlideEx srcSld = srcPres.Slides[1];
MasterSlideEx srcSldMaster = srcSld.LayoutSlide.MasterSlide;
PresentationEx dstPres = new PresentationEx(EmptyTemplateName);
int index = dstPres.Masters.AddClone(srcSldMaster);
MasterSlideEx dstSldMaster = dstPres.Masters[index];
dstPres.Slides.AddClone(srcSld, dstSldMaster);
SlideEx toChange = dstPres.Slides[1];
OleObjectFrameEx oof = (OleObjectFrameEx)toChange.Shapes[3];
Workbook w = new Workbook();
MemoryStream msIn = new MemoryStream(oof.ObjectData);
w.Open(msIn);
Worksheet ws = w.Worksheets[0];
ws.Cells[1, 1].PutValue(“Hey There!”);
// this works, but is losing the worksheet formatting…
MemoryStream msOut = new MemoryStream();
w.Save(msOut, FileFormatType.Excel2007Xlsx);
OleObjectFrameEx objectFrame = (OleObjectFrameEx)toChange.Shapes[3];
objectFrame.ObjectData = msOut.ToArray();
dstPres.Write(outFileName);
Hi Scott,
You are correct. The color scheme changes when the said xslx is saved using Aspose.Slides after updating the xslx in Aspose.Cells. An issue with issue id 13424 has been created for the fix. This thread has been associated with the issue so that you can get an automated notification as soon as it is fixed.
Muhammad,
Has there been any progress on identifying an OLEObjectFrame using FindShapeByAltText (issue 13319)?
If not, can you suggest an alternative to that method?
Thanks,
Scott
Hi Scott,
Thanks for your interest in Aspose.Slides.
The issue has almost been fixed and hopefully, we will be able to provide an intermediate version with the fix of this issue (13319) by this weekend in this thread.
Thanks and Best Regards
Hi Scott,
Thanks for your interest in Aspose.Slides.
Please find attached the intermediate version with the fix of the issue 13319 as per promise in the previous post.
Thanks and Best Regards
Muhammad,
Thank you for fixing issue #13319. The AlternateText is now available, which helps our project upgrade to use the pptx namespace.
The next issue to resolve is the colors issue #13424. That will be difficult for us to work around, and any work around would limit our client’s flexibility to change the template tremendously.
Any thoughts on that issue?
Once again, I appreciate the work that you and your team have done.
Scott
Hi Scott,
Thanks for your request in Aspose.Slides.
Well, the color scheme issue regarding xlsx sheet embedded as OLE Object in MS PowerPoint presentation requires some investigations. As soon as there is progress on this issue, you will be updated in this thread. Thanks for the appreciation.
Best Regards
Muhammad,
Any progress on issue #13424 (worksheet colors changing)? We have a delivery date rapidly approaching.
Also, I have been searching through the forum looking for an answer to the problem of the worksheet resizing after opening in the created presentation. I am setting the worksheet.SetOleSize, but it doesn’t seem to have any effect.
I noticed that there is an open issue # 11051 that seems to be exactly the problem that I am experiencing: I quote:
"On double clicking the picture (OleObjectFrame) on the slide we see the Worksheet object behind , however, the worksheet always resizes into about half the size of the object frame.
The font properties show the normal font size , font type etc.This lead me to believe that the worksheet Zoom factor is being reduced when Excel is being embedded into a Slide as an OleObjectFrame."
Has there been any progress on resolving this?
Thanks,
Scott
Muhammad,
One other observation on the resizing of the workbooks… No matter what the original size of the workbook is, and even when I use the SetOleSize, the workbooks always open to 10 rows, 7 columns.
I am attaching the original test template and the resulting presentation as an example.
This is a very simple, 2 slide presentation with a workbook that was opened, edited and saved.
The presentation that I need to get working for our client has upwards of 20 slides with workbooks. Our client very much wants to have this resolved quickly, so any help, observations or workarounds that you can give me would be greatly appreciated.
Scott
Hi Scott,
Thanks for your interest in Aspose.Slides.
The resizing of workbook does not seem to work and I have also verified the issue. An issue with issue ID 14316 has been created on our Issue Tracking System to fix the problem. This thread has also been associated with this issue, so that you can be automatically notified as soon as this issue is resolved
We are sorry for inconvenience.
Mudassir,
Regarding issue 14316, we’ve done some analysis on our own. We saved a template pptx file as a zip file and looked at the files contained inside. We then located the embedded xlsx file and saved it as
a zip file and examined the xml files inside. In particular, we located the text in the workbook.xml file. This would apparently control the number of rows/columns visible in the Ole Object Frame.
We then used Aspose Slides.Pptx and Cells to insert a value in the embedded spreadsheet. We called SetOleSize and saved the pptx to a file.
We then did the same analysis on the new pptx file and embedded xlsx file manipulated by Aspose. The corresponding workbook.xml file in the embedded xlsx does not contain an tag at all, even though we are calling SetOleSize in our code. As a result, we conclude that Excel/Powerpoint reverts to a default size of 10 rows and 7 columns when the object is opened.
We hope this information is helpful in your diagnosis and correction of the issue.
Scott
The issues you have found earlier (filed as 13319) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
If you are referring to the "Alt Text" issue # 13319, that was actually fixed in an intermediate release on 1/22/10. We have been waiting for you to address the other 2 issues: 13424 - colors changing in spreadsheet, and 14316 - embedded spreadsheet resizing. We had a deadline on our project which has passed, without fixes for these issues from you. We were able to find work arounds for the color and one of the resizing issues. But we still have an issue with the OLE container resiaing, when the user double clicks on it, to open the embedded spreadsheet. We would appreciate help on that, but are trying to find our own resolution, so we don't miss our next deadline.
Hi Scott,
We are extremely sorry for your inconvenience.
I have verified from our issue tracking system and our development team is working on your issues. Hopefully, the issues will get resolved in the next hot fix or release of Aspose.Slides for .NET. You will be automatically notified once issues are resolved.
Thanks and Regards,