OleObjectFrame pptx and adding Pic to Presentation

This method used to work when I used Aspose.Slides but now that I am using Aspose.Slides.Pptx it doesn’t work anymore. Can you tell me how I can perform the same task using the new API please.


protected void ReplaceShapeObjectData(Aspose.Slides.Shape shape, Workbook wb)
{
// Replace the values in the argument shape’s worksheet with the updated values.
OleObjectFrame shapeOOF = shape as OleObjectFrame;

shapeOOF.ObjectData = wb.SaveToStream().GetBuffer();

// get the first sheet as an image so we can replace the “object modified” image
Bitmap sheetBitmap = null;
try {
sheetBitmap = GetBitmap(wb);
} catch {
sheetBitmap = null;
}

if (sheetBitmap != null) {
// Replace the image for the worksheet in the presentation
Presentation pres = shape.Parent.Parent;
Aspose.Slides.Picture pic = new Aspose.Slides.Picture(pres, sheetBitmap);
int picID = pres.Pictures.Add(pic);
shapeOOF.PictureId = picID;
}
}

Well, I actually just saw that you guys had another release today for Aspose Total, so I got latest Dlls and my biggest issue compiling right now are here. Please tell me which reference I am missing for Aspose.cell that is causing all the problems right now.


Error 131 The type or namespace name ‘MsoLineStyle’ could not be found (are you missing a using directive or an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs

CODE:
private Aspose.Words.Drawing.ShapeLineStyle ConvertDrawingLineStyle(MsoLineStyle lineStyle)
{
// Method Code
}

private Aspose.Words.Drawing.DashStyle ConvertDrawingDashStyle(MsoLineDashStyle dashStyle)
{

Error 133 The type or namespace name ‘MsoDrawingType’ could not be found (are you missing a using directive or an assembly reference?)

CODE:
private Aspose.Words.Drawing.ShapeType ConvertDrawingShapetype(MsoDrawingType excelShapeType)
{

Error 134 The type or namespace name ‘Picture’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?)
CODE:
private Aspose.Words.Drawing.Shape ConvertPictureToShape(Aspose.Cells.Picture excelPicture, Document doc)
{
//Create new Shape
Aspose.Words.Drawing.Shape wordsShape = new Aspose.Words.Drawing.Shape(doc, Aspose.Words.Drawing.ShapeType.Image);
//Set image
wordsShape.ImageData.SetImage(excelPicture.Data);
//Import Picture properties inhereted from Shape
ImportShapeProperties(wordsShape, (Shape)excelPicture);
return wordsShape;
}

Error 135 The type or namespace name ‘Chart’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?)
CODE
private Aspose.Words.Drawing.Shape ConvertCartToShape(Aspose.Cells.Chart excelChart, Document doc)
{

AND SO ON…

Error 136 The type or namespace name ‘CheckBox’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1174 50 CACI.FM.Eas.Rendering.Base
Error 137 The type or namespace name ‘TextBox’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1217 79 CACI.FM.Eas.Rendering.Base
Error 138 The type or namespace name ‘Shape’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1250 77 CACI.FM.Eas.Rendering.Base

Hi Daniel,

I have generated the requested code snippet that works for PPTX. Please use the code snippet given below for your application and share with us if you encounter any issue. There is similar video tutorial developed for modifying the chart image and data using Aspose.Slides for Java here and it may be used as reference.

public static void ReplaceShapeExObjectData(Aspose.Slides.Pptx .ShapeEx shape, Workbook wb)

{

if (shape is OleObjectFrameEx)

{

// Replace the values in the argument shape's worksheet with the updated values.

OleObjectFrameEx shapeOOF = shape as OleObjectFrameEx;

shapeOOF.ObjectData = wb.SaveToStream().GetBuffer();

// get the first sheet as an image so we can replace the "object modified" image

Bitmap sheetBitmap = null;

try

{

sheetBitmap = GetBitmap(wb);

}

catch

{

sheetBitmap = null;

}

if (sheetBitmap != null)

{

// Replace the image for the worksheet in the presentation

PresentationEx pres = shape.Parent.Parent;

//Instantiate the ImageEx class

System.Drawing.Image img = (System.Drawing.Image)sheetBitmap;

ImageEx imgx = pres.Images.AddImage(img);

shapeOOF.FillFormat.PictureFillFormat.Picture.Image = imgx;

//or

//shapeOOF.Image = imgx;

}

}

}

Thanks and Regards,

thanks, I’ll try this new method when upgrading Aspose.Slides. However, any help with the Aspose.Cells errors I listed as well? I went from 4.8 to the newest version of Aspose.Cells and that’s why I am getting the errors now. Any idea why?

Hi,

I am a representative of Aspose.Cells team. I would help you regarding up gradation to new versions of Aspose.Cells for .NET.

While trying to keep the API as straightforward and clear as possible, we decided to recognize and honor the common development practices of the platform. Therefore, Aspose.Cells for .NET follows coding guidelines widely accepted by .NET developers. With the release of Aspose.Cells for .NET version v5.0.0, we have re-organized the API classes for Aspose.Cells component. This change has some major aspects that we follow. We have added new namespaces. All the API (classes, interfaces, enumerations, structures etc.) were previously located in the Aspose.Cells namespace. Now, certain sets of API have been moved to their relative namespaces, which make the relationship of classes (with their members) and namespaces clear and simplified.

And regarding using latest versions with their APIs, for your complete reference, I think firstly you should check the release notes for different official versions of Aspose.Cells for .NET (especially v5.0.0 and 5.1.0 etc.).
Note: Check the description under "Notable Changes for Existing Users" for API changes.
For Workbook.Open and Workbook.Save methods warning messages, please see the documents for your reference:
Moreover, please check the documentation of the product for complete details:
Let me come towards your significant errors that you may encounter, so you can fix them accordingly:
1) You need to import the relevant namesapaces to your demo pages or use fully qualified naming when declaring objects for classes etc.:
e.g
using System;
using System.Web;
using Aspose.Cells;
using Aspose.Cells.Pivot;
etc.
2) As I said above, some classes are renamed. e.g
i) Validations --> ValidationCollection
ii) PivotTable --> PivotTableCollection
etc.
3) Aspose.Cells.Style property is eliminated/obsoleted now, you should adjust your code to use Aspose.Cells.GetStyle() and Aspose.Cells.SetStyle() methods, it will also enhance the performance to certain extent:
e.g
Your sample code using Style attribute should be updated accordingly, e.g
Style style = wsNdaa.Cells[0, 0].GetStyle();
style.Font.IsBold = true;
wsNdaa.Cells[0, 0].SetStyle(style);
Styyle style2 = cells["I1"].GetStyle();
style2.HorizontalAlignment = TextAlignmentType.Center;
style2.BackgroundColor = System.Drawing.Color.Navy;
style2.Font.IsBold = true;
cells["I1"].SetStyle(style2);
For complete reference about Cell.GetStyle/SetStyle approach, please see the documents in the section:
4) Please check Aspose.Cells for .NET API Reference:


Hopefully this helps.


Now I come towards your mentioned compile time errors:

Error 131 The type or namespace name 'MsoLineStyle' could not be found (are you missing a using directive or an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs


The "MsoLineStyle" enum is now moved to Aspose.Cells.Drawing namespace, so you got to import this nampespace or use fully qualified naming.


private Aspose.Words.Drawing.DashStyle ConvertDrawingDashStyle(MsoLineDashStyle dashStyle)
{

The "MsoLineDashStyle" enum is now moved to Aspose.Cells.Drawing namespace, so you got to import this nampespace or use fully qualified naming.


Error 133 The type or namespace name 'MsoDrawingType' could not be found (are you missing a using directive or an assembly reference?)

CODE:
private Aspose.Words.Drawing.ShapeType ConvertDrawingShapetype(MsoDrawingType excelShapeType)
{

Same as Above. ---> Shape and other drawing classes are there into Aspose.Cells.Drawing namespace.

Error 134 The type or namespace name 'Picture' does not exist in the namespace 'Aspose.Cells' (are you missing an assembly reference?)
CODE:
private Aspose.Words.Drawing.Shape ConvertPictureToShape(Aspose.Cells.Picture excelPicture, Document doc)
{
//Create new Shape
Aspose.Words.Drawing.Shape wordsShape = new Aspose.Words.Drawing.Shape(doc, Aspose.Words.Drawing.ShapeType.Image);
//Set image
wordsShape.ImageData.SetImage(excelPicture.Data);
//Import Picture properties inhereted from Shape
ImportShapeProperties(wordsShape, (Shape)excelPicture);
return wordsShape;
}

Please use Aspose.Cells.Drawing.Picture (fully qualified name) or import Aspose.Cells.Drawing nampespace.

Error 135 The type or namespace name 'Chart' does not exist in the namespace 'Aspose.Cells' (are you missing an assembly reference?)
CODE
private Aspose.Words.Drawing.Shape ConvertCartToShape(Aspose.Cells.Chart excelChart, Document doc)
{


Please use Aspose.Cells.Charts.Chart as fully qualified name or import Aspose.Cells.Charts nampespace.


AND SO ON....

Error 136 The type or namespace name 'CheckBox' does not exist in the namespace 'Aspose.Cells' (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1174 50 CACI.FM.Eas.Rendering.Base
Error 137 The type or namespace name 'TextBox' does not exist in the namespace 'Aspose.Cells' (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1217 79 CACI.FM.Eas.Rendering.Base
Error 138 The type or namespace name 'Shape' does not exist in the namespace 'Aspose.Cells' (are you missing an assembly reference?) C:\Projects\EAS.OSD\CACI.FM.Eas\CACI.FM.Eas.Rendering.Base\AsposeUtility\ConverterXls2Doc.cs 1250 77 CACI.FM.Eas.Rendering.Base


All drawing shapes/controls are moved to Aspose.Cells.Drawing nampespace.


Let us know if you still find any issue.

Thank you.