https://bz.apache.org/bugzilla/show_bug.cgi?id=69629
Bug ID: 69629
Summary: Explicit style of XSSFCell does not get retrieved
Product: POI
Version: 5.4.0-FINAL
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 40010
--> https://bz.apache.org/bugzilla/attachment.cgi?id=40010&action=edit
A file to replicate the issue
I am using Apache POI XSSF to create spreadsheets where values can be resolved
dynamically (see https://github.com/DDS-GmbH/jocument).
A few days ago, I noticed an issue where in some cases the style of a cell is
not applied to a copy of the cell, but only the default style of the document.
While debugging this, I noticed that there seems to be a problem when
retrieving the explicit style of some cells (see attached file).
The code I am using to create a new cell from an existing one is the following:
```java
private Cell createNewCell(Cell templateCell) {
var newCell = currentRow.createCell(templateCell.getColumnIndex(),
templateCell.getCellType());
newCell.setCellStyle(cellStyleMap.computeIfAbsent((int)
templateCell.getCellStyle().getIndex(), i ->
copyStyle(templateCell.getCellStyle())));
return newCell;
}
private CellStyle copyStyle(CellStyle cellStyle) {
var newStyle = workbook.createCellStyle();
newStyle.cloneStyleFrom(cellStyle);
return newStyle;
}
```
Stepping into `templateCell.getCellStyle()`, I saw that
`XSSFCell#getExplicitCellStyle()` returns `null`, which is caused by
`_cell.isSetS()` returning `false`.
Looking at the xml, I can see that the value for the cell is
```xml
<c r="B2" s="17" t="s">
<v>0</v>
</c>
```
Is this some issue during parsing/workbook creation, or did I understand
something wrong?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]