private static void ModifyPowerPointCellTextContent(OpenXmlElement cell, string txt) { OXD.TextBody textbody = cell?.Descendants <OXD.TextBody>().FirstOrDefault(); if (textbody == null) { return; } OXD.TextBody final_textbody = textbody.CloneNode(true) as OXD.TextBody; OXD.Paragraph paragraph = final_textbody?.Descendants <OXD.Paragraph>().FirstOrDefault(); if (null != paragraph) { OXD.Paragraph final_paragraph = paragraph.CloneNode(true) as OXD.Paragraph; ModifyPowerPointParagraphTextContent(final_paragraph, txt); final_textbody.ReplaceChild(final_paragraph, paragraph); } cell.ReplaceChild(final_textbody, textbody); }
private static void ModifyPowerPointCellTextContent(OXD.TableCell cell, string txt) { if (null != cell) { OXD.TextBody textbody = cell.Descendants <OXD.TextBody>().FirstOrDefault(); if (null != textbody) { OXD.TextBody final_textbody = textbody.CloneNode(true) as OXD.TextBody; OXD.Paragraph paragraph = final_textbody.Descendants <OXD.Paragraph>().FirstOrDefault(); if (null != paragraph) { OXD.Paragraph final_paragraph = paragraph.CloneNode(true) as OXD.Paragraph; ModifyPowerPointParagraphTextContent(final_paragraph, txt); final_textbody.ReplaceChild <OXD.Paragraph>(final_paragraph, paragraph); } cell.ReplaceChild <OXD.TextBody>(final_textbody, textbody); } } }