Not much going on in this forum. I found out how to add data to a table in a slide so I figured I would share with the group...
Basically I have a template with a table already created on the slide. I need a way to select the table at run time and update the contents. Probably a more elegant way of doing it but it serves the purpose for me. now I need to change the background of the cell during runtime or change the font color. Any ideas?
a.
Table table = frame.Graphic.GraphicData.GetFirstChild<a.Table>();
var rows = table.Elements<a.TableRow>();
int sumOfDataPoints = dataPoints.Sum(countSum => countSum.Cnt);
foreach (var row in rows)
{
if (i > 0)
{
j = 0;
foreach (var cell in row.Elements<a.TableCell>())
{
foreach (var body in cell.Elements<a.TextBody>())
{
foreach (var p in body.Elements<a.Paragraph>())
{
foreach (var r in p.Elements<a.Run>())
{
foreach (var t in r.Elements<a.Text>())
{
j = j + 1;
//t.Text = "Row " + i + ", Column " + j + " = " + rnd.Next(5, 25).ToString();
if (j == 1)
{
try
{
t.Text = dataPoints[i - 1].Answer;
}
catch
{
}
}
else
{
try
{
int answerVal = dataPoints[i - 1].Cnt;
decimal percentage = decimal.Divide(answerVal, sumOfDataPoints) * 100;
t.Text = percentage.ToString(
"0.0")+ "%";
}
catch
{
}
}
}
}
}
}
}
}
i = i + 1;