Create a new or cloned XSSFCellStyle from another XSSFCellStyle (POI APACHE)

Demand

I need a new XSSFCellStyleone because I need to change some styles.

Situation

I have only XSSFCellStyle- I do not XSSFCellhave to which it belongs. Thus, I also do not have access to connected XSSFSheetor XSSFWorkbook.

What have i tried

  • I don’t have XSSFWorkbook, so I can’t call workbook.createCellStyle().
  • The constructor XSSFCellStyleneeds at least one StylesTablethat I also don’t have (because I could not find a way to get it from the old one XSSFCellStyle).
  • cellStyle.cloneStyleFrom(XSSFCellStyle Source) doesn’t actually clone the style (it is more or less just a copy with the same pointers, so if I change something on the same cellStyle, the “cloned” cellStyle has the same changes).

Question

How can i get a new one XSSFCellStyle?

Regards, winklerrr

+4
source share
2 answers

The method XSSFCellStyleis available . clone()XSSFCellStyle
I do not know why, but I did not see him in the first place. My bad.

0
source

- , Excel xls/xlsx, /. , . - , .

-

  XSSFCellStyle clone = wb.createCellStyle();
  clone.cloneStyleFrom(origStyle);

.

XSSFCellStyle.clone(), , , , , Style, ...

+5

Source: https://habr.com/ru/post/1611558/


All Articles