Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Tue Oct 17, 2017 10:16 am

Hi,
I there any way to add shapes(not images) in specified tables cell.
Thx Ashish

bansalgi
 
Posts: 1
Joined: Tue Oct 17, 2017 10:11 am

Wed Oct 18, 2017 4:04 am

Hello Ashish,

Thanks for your inquiry.
Sorry there's no direct way to add a shape to a certain cell. Anyway, you could draw a shape to the corresponding position in the cell. Kindly note this process requires a calculation of the position. Please refer to the sample demo and attached is the generated file.
Code: Select all
 //create PPT document
            Presentation presentation = new Presentation();

            //add new table of 3row and 5column to PPT
            Double[] widths = new double[] { 120, 120, 120, 120, 120 };
            Double[] heights = new double[] { 25, 25, 25 };
            float tableX = presentation.SlideSize.Size.Width / 2 - 275;
            ITable table = presentation.Slides[0].Shapes.AppendTable(tableX, 80, widths, heights);

            for (int i = 0; i < heights.Length; i++)
            {
                for (int j = 0; j < widths.Length; j++)
                {
                    //calculate the positions
                    int cellx = (int)(tableX + 53 + j * 120);
                    int celly = (int)(80 + 5 + i * (25 + 2 * i));

                    //draw shapes
                    table[j, i].Slide.Shapes.AppendShape(ShapeType.Triangle, new Rectangle(cellx, celly, 15, 15));
                }
            }
            //save the document
            presentation.SaveToFile("ShapesInTable.pptx", FileFormat.Pptx2010);


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue Oct 24, 2017 8:29 am

Hello,

Greetings from E-iceblue support team.
Has your issue been resolved?
Thanks in advance for your valuable feedback and time.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Presentation