c# - How to find the paragraph node is within the table node in OpenXML -
i have tried in following code sample ancestor property find paragraph node within table node it's not working cases.
using (wordprocessingdocument docx = wordprocessingdocument.open(docxstream, true)) { body docxbody = docx.maindocumentpart.document.body; list<openxmlelement> eachpara = new list<openxmlelement>();//paragraph element foreach (openxmlelement bodychild in docxbody.childelements) { if (bodychild paragraph) { if (bodychild.ancestors<table>().tolist().count > 0) { } } } // list<openxmlelement> eachpara = docxbody.childelements.tolist().where(eachchild => eachchild paragraph).tolist(); foreach (openxmlelement lstpara in eachpara) { if (lstpara.childelements.any(ch => ch.localname.tolower().equals("run"))) { } else { } } }
Comments
Post a Comment