ASPxPivotGrid中使用CustomCellDisplayText后,用ASPxPivotGridExporter导出XLS等时,自定义的值为0或空的解决。

因为ASPxPivotGridExporter的默认导出,是按value导出的,而自定义列的value原本就是空的,只是TEXT是在CustomCellDisplayText中动态赋值,因为在默认状态下,导出时没有值。

 

解决方法,只需要在ASPxPivotGridExporter导出时,指定DevExpress.XtraPrinting.TextExportMode.Text即可。就可以按DisplayText的内容导出了。

 

 

ASPxPivotGridExporter4.ExportXlsToResponse("县人大选举选票回收统计", DevExpress.XtraPrinting.TextExportMode.Text, true);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
使用easyExcel导出,可以通过自定义转换器来实现将Integer类型的字典数据导出为具体的。 首先,创建一个自定义转换器类,实现Converter接口,重写convertToExcelData和convertToJavaData方法,在convertToExcelData方法Integer类型的字典数据转换为具体的,如下所示: ```java public class DictionaryConverter implements Converter<Integer> { private Map<Integer, String> dictionaryMap; public DictionaryConverter(Map<Integer, String> dictionaryMap) { this.dictionaryMap = dictionaryMap; } @Override public Class<?> supportJavaTypeKey() { return Integer.class; } @Override public CellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { String dictionaryValue = dictionaryMap.get(value); if (StringUtils.isNotBlank(dictionaryValue)) { return new CellData<>(dictionaryValue); } return new CellData<>(""); } @Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { return null; } } ``` 其,dictionaryMap是一个字典映射表,存储了Integer类型的与具体之间的对应关系。 然后,在使用easyExcel进行导出,通过@ExcelProperty注解设置自定义转换器即可: ```java @ExcelProperty("状态") @Convert(converter = DictionaryConverter.class) private Integer status; ``` 这样,在导出Integer类型的字典数据就会被转换成具体的了。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值