Springmvc使用hutool导出excel中文文件名乱码问题

时间:2025-03-10 10:04:56

Springmvc使用hutool导出excel中文文件名乱码问题,原因是tomcat本身没有设置UTF-8,或者字符集问题。

未知原因很多。这些都可以通知对文件名使用 来解决。

        //response为HttpServletResponse对象
        ("application/-excel;charset=utf-8");

        //中文编码
        String fileName = ("入住记录", "UTF-8");
        ("Content-Disposition","attachment;filename="+fileName+".xls");
        ServletOutputStream out=();


        ExcelWriter writer = ();
        // 合并单元格后的标题行,使用默认标题样式
        (9, "入住记录列表");
// 一次性写出内容,使用默认样式
        (rows);
        (out);

        ();