How to add an image in Table Cell via Spire.Presentation

2015-03-12 06:11:40 Written by  support iceblue
Rate this item
(0 votes)

Adding an image in table cell can make your PPT files more different. Spire.Presentation allows developers add images to table cells. Here we introduce an example to add an image to a table cell in PPT.

Step 1: Create a new PPT document instance.

Presentation presentation = new Presentation();

Step 2: Call AppendTable() method to create a table and set the table style.

ISlide slide = presentation.Slides[0];
Double[] widths = new double[] { 100, 100};
Double[] heights = new double[] { 100, 100};
ITable table = presentation.Slides[0].Shapes.AppendTable(100, 80, widths, heights);
table.StylePreset = TableStylePreset.LightStyle1Accent2;

Step 3: Use table[0, 0].FillFormat.PictureFill.Picture.EmbedImage to embed the image to the cell. The FillType can be changed.

IImageData imgData = presentation.Images.Append(Image.FromFile("1.jpg"));
table[0, 0].FillFormat.FillType = FillFormatType.Picture;
table[0, 0].FillFormat.PictureFill.Picture.EmbedImage = imgData;
table[0, 0].FillFormat.PictureFill.FillType = PictureFillType.Stretch;

Step 4: Save and review.

presentation.SaveToFile("table.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("table.pptx");

Here is the screenshot:

How to add an image in Table Cell via Spire.Presentation

Additional Info

  • tutorial_title: Add an image in Table Cell
Last modified on Friday, 24 September 2021 09:22