private void setText(String text, wp.TableCell theCell) { wp.Text _text = theCell.Descendants<wp.Text>().First(); _text.Text = text; }
private static void ModifyWordParagraphTextContent(OXW.Paragraph paragraph, string txt) { if (null != paragraph) { OXW.Run run = paragraph.Descendants<OXW.Run>().FirstOrDefault(); if (null != run) { run = run.CloneNode(true) as OXW.Run; paragraph.RemoveAllChildren<OXW.Run>(); } else { run = new OXW.Run(); } OXW.Text text = run.Descendants<OXW.Text>().FirstOrDefault(); text = (null == text ? new OXW.Text() : text.CloneNode(true) as OXW.Text); run.RemoveAllChildren<OXW.Text>(); text.Text = txt; if (!string.IsNullOrEmpty(txt) && (char.IsWhiteSpace(txt[0]) || char.IsWhiteSpace(txt[txt.Length-1]))) { text.Space = SpaceProcessingModeValues.Preserve; } run.Append(text); paragraph.Append(run); } }
private static void ModifyWordRowTextContent(OXW.TableRow headerRowTemplate, string txt) { if (null != headerRowTemplate) { var cells = headerRowTemplate.Descendants<OXW.TableCell>(); if (null != cells) { foreach (var cell in cells) { ModifyWordCellTextContent(cell, txt); } } } }
private static void ModifyWordCellTextContent(OXW.TableCell cell, string txt) { if (null != cell) { OXW.Paragraph paragraph = cell.Descendants<OXW.Paragraph>().FirstOrDefault(); if (null != paragraph) { paragraph = paragraph.CloneNode(true) as OXW.Paragraph; ModifyWordParagraphTextContent(paragraph, txt); cell.RemoveAllChildren<OXW.Paragraph>(); cell.Append(paragraph); } } }