本文介绍了从另一个 XSSFCellStyle (POI APACHE) 创建新的或克隆 XSSFCellStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个新的 XSSFCellStyle
因为我必须改变一些样式.
I need a new XSSFCellStyle
because I have to change some stylings.
我只有一个 XSSFCellStyle
- 我没有它所属的 XSSFCell
.因此,我也无权访问相关的 XSSFSheet
或 XSSFWorkbook
.
I only have a XSSFCellStyle
- I don't have the XSSFCell
it belongs to. Thus I also don't have access to the related XSSFSheet
or XSSFWorkbook
.
- 我没有
XSSFWorkbook
,因此我无法调用workbook.createCellStyle()
. XSSFCellStyle
构造函数至少需要一个StylesTable
,我也没有(因为我找不到从旧的XSSFCellStyle
).cellStyle.cloneStyleFrom(XSSFCellStyle Source)
并没有真正克隆样式(它或多或少只是具有相同指针的副本,因此如果我在一个 cellStyle 上更改某些内容,克隆"; cellStyle 有相同的变化).
- I don't have the
XSSFWorkbook
therefore I can't callworkbook.createCellStyle()
. - The
XSSFCellStyle
constructor needs at least aStylesTable
which I also don't have (because I couldn't find a way to get it from the oldXSSFCellStyle
). - The
cellStyle.cloneStyleFrom(XSSFCellStyle Source)
doesn't really clone the style (it's more or less just a copy with the same pointers, so if I change something on one cellStyle the "cloned" cellStyle has the same changes).
如何获得新的XSSFCellStyle
?
问候,winklerrr
Regards, winklerrr
推荐答案
XSSFCellStyle
上有一个 clone()
方法可用.
我不知道为什么,但我一开始没有看到它.我的错.
There is a clone()
method available on the XSSFCellStyle
.
I don't know why but I didn't see it in the first place. My bad.
这篇关于从另一个 XSSFCellStyle (POI APACHE) 创建新的或克隆 XSSFCellStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!