dotnetcore/NPOI

NPOI docx的word 表格,怎么复制并插入上一行。

doneself opened this issue · 1 comments

NPOI里面docx的表格每行的列不一样的时候,没有找到很好的复制一行,然后插入到表格末尾的办法。

搜了一下,看到别人的做法。

for (int j = 0; j < oldRow.GetTableCells().Count; j++)
{
          newRow.CreateCell();
          CT_Tc cttc1 = newRow.GetCell(j).GetCTTc();
          CT_TcPr tcpr1 = cttc1.AddNewTcPr();
          tcpr1.tcW = oldRow.GetCell(j).GetCTTc().tcPr.tcW;
          tcpr1.tcBorders = oldRow.GetCell(j).GetCTTc().tcPr.tcBorders;
          tcpr1.tcMar = oldRow.GetCell(j).GetCTTc().tcPr.tcMar;
          tcpr1.gridSpan = oldRow.GetCell(j).GetCTTc().tcPr.gridSpan;
}