Search before asking
Fesod version
2.0.2-incubating
JDK version
11
Operating system
Windows 11
Steps To Reproduce
public class AlwaysZeroIntegerConverter implements Converter<Integer> {
public Class<?> supportJavaTypeKey() { return Integer.class; }
public CellDataTypeEnum supportExcelTypeKey() { return CellDataTypeEnum.NUMBER; }
public Integer convertToJavaData(...) { return 0; } // deliberately wrong, so it's unmistakable
public WriteCellData<?> convertToExcelData(WriteConverterContext<Integer> ctx) {
return new WriteCellData<>(new BigDecimal(999)); // deliberately wrong, so it's unmistakable
}
}
public class IntRow {
@ExcelProperty("n")
private Integer n; // will be set to 42
}
// ...
IntRow row = new IntRow();
row.setN(42);
FesodSheet.write(file, IntRow.class)
.registerConverter(new AlwaysZeroIntegerConverter())
.sheet()
.doWrite(List.of(row));
Current Behavior
It writes 42 into the xlsx file, instead of 999
Expected Behavior
it should write 999 into the xlsx file
Anything else?
RCA: Built in write converters are keyed by Java Type but these custom converters are keyed by both java type and excel cell type. At the write time only converts keyed by java type are searched causing the write path to completely ignore the custom converters
Fix would be to key it by java type only in the AbstractWriteHolder
Happy to share a PR for this!
Are you willing to submit a PR?
Search before asking
Fesod version
2.0.2-incubating
JDK version
11
Operating system
Windows 11
Steps To Reproduce
Current Behavior
It writes 42 into the xlsx file, instead of 999
Expected Behavior
it should write 999 into the xlsx file
Anything else?
RCA: Built in write converters are keyed by Java Type but these custom converters are keyed by both java type and excel cell type. At the write time only converts keyed by java type are searched causing the write path to completely ignore the custom converters
Fix would be to key it by java type only in the
AbstractWriteHolderHappy to share a PR for this!
Are you willing to submit a PR?