I was trying to use NPOI to create a word document from a template.Inside the document I was trying to insert a table in a table cell.The table cell has two paragraphs, I was trying to insert a table between the two paragraphs.
Here is my solution: In the template, create a table between the two paragraphs to replace.
CT_Tbl tbl = new CT_Tbl();
int index = cell.GetCTTc().Items.IndexOf(cell.Tables[0].GetCTTbl());
cell.GetCTTc().Items.RemoveAt(index);
cell.GetCTTc().Items.Insert(index, tbl);
int rowCount = dtData.Rows.Count;
int columnCount = dtData.Columns.Count;
XWPFTable xTable = new XWPFTable(tbl, body, rowCount, columnCount);