XWPFTableRow用当前样式添加新的Row? [英] XWPFTableRow adding new Row with current style?

查看:257
本文介绍了XWPFTableRow用当前样式添加新的Row?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Apache POI将新行添加到现有XWPFTable上,以使添加的行保留最后一行的样式(字体,颜色等).通常,XWPFTable.createRow()返回具有空白样式的行.我尝试使用最后一行的CTRow作为构造参数和XWPFTable.addRow()创建新的XWPFTableRow对象.但是,当我创建对象时,它仅引用最后一行(对对象所做的任何更改都会反映在最后一行上,而不是新添加的).

I try to use Apache POI to add new row onto the existing XWPFTable such that the row added is hold the style (font, color, etc.) of the last row. Normally, XWPFTable.createRow() returns a row with blank style. I tried to create new XWPFTableRow object using the last row's CTRow as construction parameter and XWPFTable.addRow(). However, when I created the object, it simply reference the last row (whatever change is made to the object is reflected upon the last row, not the newly added one).

我该如何解决?

推荐答案

我知道这是一个老问题,但这也许对某人有用:

I know it's an old question, but maybe this is useful to someone:

xwpfTable.addRow( xwpfTable.getRow( xwpfTable.getRows().size() - 1 ) );

在表末尾添加一个新行,与最后一行相同.

Adds a new row at the end of the table, identical to the last row.

这篇关于XWPFTableRow用当前样式添加新的Row?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆