从另一个 XSSFCellStyle (POI APACHE) 创建新的或克隆 XSSFCellStyle [英] Create new or clone XSSFCellStyle from another XSSFCellStyle (POI APACHE)

查看:51
本文介绍了从另一个 XSSFCellStyle (POI APACHE) 创建新的或克隆 XSSFCellStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个新的 XSSFCellStyle 因为我必须改变一些样式.

I need a new XSSFCellStyle because I have to change some stylings.

我只有一个 XSSFCellStyle - 我没有它所属的 XSSFCell.因此,我也无权访问相关的 XSSFSheetXSSFWorkbook.

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 call workbook.createCellStyle().
  • The XSSFCellStyle constructor needs at least a StylesTable which I also don't have (because I couldn't find a way to get it from the old XSSFCellStyle).
  • 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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