GroupShape and Table

In my code I check if (shape is Table) and just then if (shape is GroupShape). Can you please tell me how can I know if shape is table and do not handle line table drawing and TextFrame output if I’m in if (shape is GroupShape) section?

Why you can’t check (shape is Table) again?

I don’t now why Smile.

This is my code:


[code language=“c#”] 

for(int j = 0; j < slide.Shapes.Count; j++)

{
Shape shape = slide.Shapes[j];
if (shape is Table)

{

… // work with table

}

if (shape is TextFrame)

{

… // work with TextFrame
}
if (shape is Line)

{

… //work with line shape

}



if (shape is GroupShape)

{







for(int k = 0; k < ((GroupShape)shape).Shapes.Count; k++)

{

Shape shape1 = ((GroupShape)shape).Shapes[k];



if (shape1 is Table)




{







// never occurs


}





if (shape1 is TextFrame)

{

… // work with TextFrame
}
if (shape1 is Line)

{

… //work with line shape

}




}

}

}

Hi Alexey,

when are you going to answer?

Dear CAV,

if (shape1 is Table)
What is it? Are you looking for a table which is grouped with another shape?
I’m not sure but I thought PowerPoint doesn’t allow to group tables with shapes.
May be “if (shape is Table)” will be more correct?

shape instead of shape1 Yes Big Smile thanks

A question:

for(int j = 0; j < slide.Shapes.Count; j++)
{
Shape shape = slide.Shapes[j];
if (shape is Table)
{
Table sh = (Table)shape;
Color clr = sh.LineFormat.ForeColor; //null
clr = sh.FillFormat.ForeColor; //null
}
}

how can i get Table.LineFormat and Table.FillFormat?

You can get FillFormat from TextFrame.FillFormat for each cell.
LineFormat can be retrieved only from Lines if you read table as GroupShape.

“You can get FillFormat from TextFrame.FillFormat for each cell.” - ok, but “LineFormat can be retrieved only from Lines if you read table as GroupShape.” - i read table as Table and i need LineFormat.ForeColor for Table. (I can’t set any parameters for table outside the “if (shape is Table)” block). If i get Parent element for (Table)shape it return Slide element instead GroupShape element.

Table class inherited from GroupShape so it has Shapes property.
Shapes contains TextFrames and Lines. Lines are cell’s borders and have LineFormat property.

I now that Table have LineFormat but it for some reason is null.

Did you read my explanation? You shouldn’t get LineFormat from Table.

Table t = Shapes[…] as Table;
if (t != null)
{
GroupShape gs = (GroupShape)t;
for (int i = 0; i < gs.Shapes.Count; i++)
{
Line line = gs.Shapes[ i ] as Line;
if (line != null)
{
do something with line.LineFormat;
}
}
}