How to insert a Image in to Aspose.Slides.Table cell

Hi,

How to insert a image in to Aspose.Slides.Table cell with custom height and width.

And how to add another table in to Aspose.Slides.Table cell

Please let me know ASAP

Thanks

Dear Mrudula,

You cannot insert image into cell of the table. But you can insert image and then adjust cell’s height and width in such a way that cell appears to contain your image.

You cannot also insert table inside another table.

For inserting picture, please see this link.

http://www.aspose.com/documentation/file-format-components/aspose.slides-for-.net-and-java/adding-picture-frame-to-slide.html

For increasing cell’s height and width, you can use Table.SetColumnWidth or Table.SetRowHeight methods and to get cell’s dimensions, you can use Cell.TextFrame.X, Y, Width, Height properties.

Hi,


We are trying to build a presentation using the Aspose.Slides .net component.
One of the critical requirements is an ability to insert into Aspose.Slides.Table cell.

I found this post 3 years old. Question, isn’t this issue still resolved? We really really need to insert images into cells. How can we do that?

Kind Regards,
Alexey

Hi Alexey,


Please use the code snippet given below to add the image inside table cell. Please share with us if I may help you any further in this regard. I have used Aspose.Slides for .NET 5.6.0

Presentation pres = new Presentation();

//Creating a picture object that will be used to fill the ellipse
Picture pic = new Picture(pres, @“C:\Users\Public\Pictures\Sample Pictures\Desert.jpg”);

//After the picture object is added, the picture is given a uniqe picture Id
int picId = pres.Pictures.Add(pic);


Slide sld = pres.GetSlideByPosition (1);

Table tbl = sld.Shapes.AddTable(50, 100, 1500, 500, 3, 3);
tbl.GetCell(0, 0).FillFormat.Type =FillType.Picture ;

tbl.GetCell(0, 0).FillFormat.PictureId = picId;
pres.Write(“d:\Aspose Data\TableImage.ppt”);


Many Thanks,

Hi Mudassir,


Thank you very much! That approach works.
Trying to get this image scaled correctly now.

Kind Regards,
Alexey

Is it possible to do this using JAVA?

Hi Ashwin,

Please try using following sample code to add image inside java table cell.

public static void AddTbaleCellImage()
{
//Instantiate Presentation class object
Presentation pres = new Presentation();

//Access first slide
ISlide sld = pres.getSlides().get_Item(0);

//Define columns with widths and rows with heights
double[] dblCols = { 150, 150, 150, 150 };
double[] dblRows = { 100, 100, 100, 100, 90 };

//Add table shape to slide
ITable tbl = sld.getShapes().addTable(50, 50, dblCols, dblRows);

//Creating an Image object to hold the image file
IPPImage imgx = null;
try {
imgx = pres.getImages().addImage(new FileInputStream(new File(“aspose1.jpg”)));
} catch (IOException e) {
}

//Create an IPPImage object using the bitmap object
IPPImage imgx1 = pres.getImages().addImage(imgx);

//Add image to first table cell
tbl.get_Item(0, 0).getFillFormat().setFillType(FillType.Picture);
tbl.get_Item(0, 0).getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
tbl.get_Item(0, 0).getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);

//Save PPTX to Disk
pres.save(“D:\Data\table.pptx”, SaveFormat.Pptx);

}

Many Thanks,

Thanks! Also, I was wondering how you would insert a shape into a table cell as well using java?

Hi Ashwin,

I have observed your requirement and like to share that as per my knowledge one cannot add a shape inside table cell. Also this is not possible using Aspose.Slides as well. If you are some how able to achieve that in PowerPoint on your end then please share a sample presentation with us having shape inside table cell and we will log new feature request.

Many Thanks,