下面的代码是java的,稍微修改即可适合C#
添加列需要遍历每一行,然后在最后一个单元格后面再插入一个单元格
//Open document
Document doc = new Document("C:\\Temp\\in.doc");
//Get table from the document
Table tab = doc.getFirstSection().getBody().getTables().get(0);
//Add few more columns
for(int i=0; i<3; i++)
{
for(Row row : tab.getRows())
{
//clone las cell of the row and append it to the row
Node cellClone = row.getLastCell().deepClone(true);
row.appendChild(cellClone);
}
}
//Save output document
doc.save("C:\\Temp\\out.doc");