Hi,
I am using following extension method in order to set font size in table cell:
public static void SetCellFontSize(this Cell cell, double fontSize)
{
var runs = cell.GetChildNodes(NodeType.Run, true);<span style="color:blue;">foreach</span> (<span style="color:#2b91af;">Run</span> run <span style="color:blue;">in</span> runs) { run.Font.Size = fontSize; } }</pre></div><div>I am using this method when populating existing table in Word document like this:</div><div><pre style="font-family: Consolas; font-size: 13px; background: white;"><span style="color:blue;"> private</span> <span style="color:#2b91af;">Table</span> PopulateCoursesSummary(<span style="color:#2b91af;">StudentTranscript</span> data, <span style="color:#2b91af;">Document</span> wordDocument) { <span style="color:green;">//Courses summary</span> <span style="color:blue;">var</span> coursesSummaryTable = (<span style="color:#2b91af;">Table</span>)wordDocument.GetChild(<span style="color:#2b91af;">NodeType</span>.Table, 1, <span style="color:blue;">true</span>); coursesSummaryTable.Alignment = <span style="color:#2b91af;">TableAlignment</span>.Left; <span style="color:blue;">foreach</span> (<span style="color:blue;">var</span> course <span style="color:blue;">in</span> data.Courses) { <span style="color:blue;">var</span> clonedRow = (<span style="color:#2b91af;">Row</span>)coursesSummaryTable.Rows[coursesSummaryTable.Rows.Count - 2].Clone(<span style="color:blue;">true</span>); <span style="color:green;">//Empty cloned row</span> <span style="color:blue;">foreach</span> (<span style="color:#2b91af;">Cell</span> cell <span style="color:blue;">in</span> clonedRow.Cells) { cell.RemoveAllChildren(); cell.EnsureMinimum(); } <span style="color:green;">//populate cloned row with data</span> clonedRow.Cells[0].FirstParagraph.Runs.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">Run</span>(wordDocument, course.Name)); clonedRow.Cells[1].FirstParagraph.Runs.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">Run</span>(wordDocument, course.Status)); clonedRow.Cells[2].FirstParagraph.Runs.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">Run</span>(wordDocument, course.Date)); <span style="color:green;">//Change font in cloned row</span> <span style="color:blue;">foreach</span> (<span style="color:#2b91af;">Cell</span> cell <span style="color:blue;">in</span> clonedRow.Cells) { cell.SetCellFontSize(8); } <span style="color:green;">//insert cloned row as last row in table</span> coursesSummaryTable.Rows.Insert(-1, clonedRow); } <span style="color:blue;">return</span> coursesSummaryTable; }</pre></div><div>This works as expected when data added to cell is not an empty string. If, e.g course.Date==String.Empty, then cell font size will be 11 (not 8) by default. Why? </div><div><br></div><div>Please let me know if I can change this to suit my needs.</div><div><br></div><div>Cheers</div><div><br></div><div>P.S. I know that I can work around this - add some dummy text to that cell and make it white to be invisible, but I would like not to have things like this in my code :)</div>