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

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

问题描述

我尝试使用 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).

我该如何解决这个问题?

How do I get around with this?

推荐答案

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

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 添加具有当前样式的新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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