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

Free Support Forum - aspose.com

How to insert image in table's cell

I am creating a table using aspose slides java

my requirement is to add a image in a particular cell of that table. Is that possible?


This message was posted using Email2Forum by Tahir Manzoor.

Hi Arpit,

Please see the following sample code to add image in a table cell using Aspose.Slides for Java.


//Instantiate PresentationEx class that represents PPTX file
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 a Buffered Image object to hold the image file
BufferedImage image=null;

image = ImageIO.read(new File(“D:\Data\image1.jpg”));
IPPImage imgx1 = pres.getImages().addImage(image);

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(imgx1);

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

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi,


Thanks for the solution.

Just one thing more.

I want a small image in particular cell .
I mean i can specify the position of image within a cell rather than covering the whole cell with the image.

Thanks

Arpit

Hi Arpit,

I have observed your requirements and like to share that there is no option in my knowledge available in PowerPoint even to set the image of the cell at particular position. All that is possible is to set the fill style of cell to an image that has already been shared with you. If there is an option available to set the image position inside cell then please share the sample presentation with us and I will try my best to help you further in this regard.

Many Thanks,