Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导出excel失败: java.lang.NumberFormatException: For input string: "2023-12-19 19:00:00" #114

Open
yichengxian opened this issue Apr 19, 2024 · 0 comments

Comments

@yichengxian
Copy link

yichengxian commented Apr 19, 2024

版本:1.4.7
JDK版本:
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)

出现问题:
报错位置 :org.jeecgframework.poi.excel.export.base.ExcelExportBase#createStringCell
具体报错信息
java.lang.NumberFormatException: For input string: "2023-12-19 19:00:00"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at org.jeecgframework.poi.excel.export.base.ExcelExportBase.createStringCell(ExcelExportBase.java:426)

复现逻辑:

//对象一个字段设置: @Excel(name = "费用", width = 15, numFormat = "0.00", type = 4) private BigDecimal totalMoney; // 下一个字段设计: @Excel(name = "报修时间", width = 18, format = "yyyy-MM-dd HH:mm:ss") private Date createTime;
导出 方法类

`
/**
* @param exportList 导出数据
* @param clazz 类型
* @param title 标题
* @return
*/
public static ModelAndView exportExtXls(List exportList, Class clazz, String title,String[] exportFields) {

    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    //i 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
    mv.addObject(NormalExcelConstants.CLASS, clazz);
    ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + (null != sysUser ? sysUser.getRealname() : "管理员") + DateUtil.formatChineseDate(new Date(), false, true), title);

    mv.addObject(NormalExcelConstants.PARAMS, exportParams);
    mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
    if (ArrayUtil.isNotEmpty(exportFields)){
        mv.addObject(NormalExcelConstants.EXPORT_FIELDS, Arrays.stream(exportFields).collect(Collectors.joining(",")));
    }

    return mv;
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant