You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also believe that this logic needs to be further optimized.
FYI, based on my understanding, I believe we should continue exploring how to better configure global converters, and should permit a type to have multiple converters.
I also believe that this logic needs to be further optimized.
FYI, based on my understanding, I believe we should continue exploring how to better configure global converters, and should permit a type to have multiple converters.
Such as :
when the same type has multiple converters, in a NoModel (no @ExcelProperty) setup where several fields of the same type each need different conversion logic, doConvert can just loop through (or use some other approach) to pick out the best-matching converter.
Thinking about it this way, it actually makes sense.
My understanding of the source code might be a bit one‑sided, so apologies if I got anything wrong.
Activity
delei commentedon Oct 17, 2025
Could you please provide the
ExcelTestentity class?liuyier commentedon Oct 17, 2025
@DaTa
@accessors(chain = true)
@ExcelIgnoreUnannotated
@ColumnWidth(20)
@HeadRowHeight(20)
@ContentRowHeight(15)
@headstyle(borderBottom = BorderStyleEnum.DOTTED, borderLeft = BorderStyleEnum.DOTTED, borderRight = BorderStyleEnum.DOTTED, borderTop = BorderStyleEnum.DOTTED,fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 9)
@HeadFontStyle(fontHeightInPoints = 12)
@ContentStyle(borderBottom = BorderStyleEnum.DOTTED, borderLeft = BorderStyleEnum.DOTTED, borderRight = BorderStyleEnum.DOTTED, borderTop = BorderStyleEnum.DOTTED,horizontalAlignment = HorizontalAlignmentEnum.CENTER)
@ContentFontStyle(fontHeightInPoints = 11)
public class ExcelTest {
}
很常规的一个实体,
liuyier commentedon Oct 17, 2025
@Encrypt
是我自定义注解,可以删掉。
delei commentedon Oct 17, 2025
Please give it a try using
liuyier commentedon Oct 17, 2025
这样子可以进入断点并生效。
但其实我的目的是加入到全局配置中,而不是单个字段加convert属性,那太麻烦了,也不现实。
delei commentedon Oct 17, 2025
Please try to modify the custom Converter, override the
supportExcelTypeKeymethod and return null.ExcelTestentity classFYI, based on my understanding, this may affect all BigDecimal-type properties. Please thoroughly test according to your actual use case.
liuyier commentedon Oct 20, 2025
我刚测试了下,重写supportExcelTypeKey方法后,确实是生效了。
这是什么原因,我在1.2.0版本上没有重写这个方法可以正常使用。
但升到了1.3.0还需要重写supportExcelTypeKey方法并返回 return null ?啊这。。
delei commentedon Oct 20, 2025
Please refre to issue #170 and PR #322
liuyier commentedon Oct 21, 2025
没太明白, 我还是退回1.2.0好了。
fix 修复 全局处理器不生效问题 根据官方issue改为特殊写法(不理解为什么 apache/fesod#648)
fix 修复 全局处理器不生效问题 根据官方issue改为特殊写法(不理解为什么 apache/fesod#648)
bengbengbalabalabeng commentedon Oct 30, 2025
问题触发条件
初步分析
问题的根源在于
AbstractExcelWriteExecutor#doConvert方法中获取全局转换器的逻辑。cn.idev.excel.write.metadata.holder.AbstractWriteHolderCode
cn.idev.excel.write.executor.AbstractExcelWriteExecutor#doConvertCode
在
ExcelWriteAddExecutor#add方法(调用链)中,会先构造一个CellWriteHandlerContext对象,但此时并没有对targetCellDataType字段进行赋值。随后调用converterAndSet->doConvert时,如果@ExcelProperty注解未显式指定converter,就会进入全局Converter<?>的获取逻辑。然而,当 [Mark-2] 条件不成立时,[Mark-3] 中的
TargetCellDataType会一直保持为NULL。这会导致通过 [Mark-1] 添加的Converter<?>无法被正确匹配,从而抛出异常。讨论
是否需要在 [Mark-1] 添加 excelTypeKey(感觉
CellWriteHandlerContext#targetCellDataType类型赋值问题不好解)个人觉得通过 registerConverter() 同时注册多个相同类型的全局 Converter 本身不太合理,应该使用 @ExcelProperty(converter = ...) 显式指定会更好(优先级高)。
delei commentedon Oct 30, 2025
Hi, @bengbengbalabalabeng
I also believe that this logic needs to be further optimized.
FYI, based on my understanding, I believe we should continue exploring how to better configure global converters, and should permit a type to have multiple converters.
bengbengbalabalabeng commentedon Oct 30, 2025
Such as :
when the same type has multiple converters, in a NoModel (no @ExcelProperty) setup where several fields of the same type each need different conversion logic,
doConvertcan just loop through (or use some other approach) to pick out the best-matching converter.Thinking about it this way, it actually makes sense.
My understanding of the source code might be a bit one‑sided, so apologies if I got anything wrong.
JusChui commentedon Mar 16, 2026
已解决!我在2.0.1-incubating版本仍然遇到这个问题,我编写了文件导出工具类,定义了脱敏注解和org.apache.fesod.sheet.converters.Converter的实现类,通过registerConverter(new XxxxxConverter())注册converter,但还是仅当使用注解@ExcelProperty(value = "xxx", converter = XxxxxConverter.class)时显式指定converter 才能进入自定义处理器,然后重写了处理器,通过实现org.apache.fesod.sheet.write.handler.CellWriteHandler接口重写afterCellDispose方法而非实现org.apache.fesod.sheet.converters.Converter,再通过 FesodSheet.write(response.getOutputStream(), clazz)
.registerWriteHandler(new XxxxxCellWriteHandler())注册处理器解决问题。
update springboot 3.5.6 => 3.5.7
fix 修复 全局处理器不生效问题 根据官方issue改为特殊写法(不理解为什么 apache/fesod#648)