c# aspose.words word表格都是添加行,怎么添加列?
2条回答 默认 最新
- threenewbee 2019-09-24 19:08关注
下面的代码是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");
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报