dromara / hutool

🍬A set of tools that keep Java sweet.
https://hutool.cn
Other
29.24k stars 7.53k forks source link

合并单元格,写入内容为空 #3775

Closed itflash closed 3 weeks ago

itflash commented 4 weeks ago

版本情况

JDK版本: 1.8.0_301 hutool版本: 5.8.32

问题描述(包括截图)

合并单元格,写入内容为空

  1. 复现代码
        List<String> row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd");
        List<String> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1");
        List<String> row3 = CollUtil.newArrayList("aa2", "bb2", "cc2", "dd2");
        List<String> row4 = CollUtil.newArrayList("aa3", "bb3", "cc3", "dd3");
        List<String> row5 = CollUtil.newArrayList("aa4", "bb4", "cc4", "dd4");

        List<List<String>> rows = CollUtil.newArrayList(row1, row2, row3, row4, row5);

        //通过工具类创建writer
        ExcelWriter writer = ExcelUtil.getWriter("G:\\project\\writeTest.xlsx");

        //跳过当前行,既第一行,非必须,在此演示用
//        writer.passCurrentRow();

        //合并单元格后的标题行,使用默认标题样式
        writer.merge(row1.size() , "测试标题");
        writer.merge(1, 5, 4, 4, "11111", false);
        //一次性写出内容,强制输出标题
        writer.write(rows, true);
        //关闭writer,释放内存
        writer.close();
  1. 测试涉及到的文件(注意脱密)

比如报错的Excel文件,有问题的图片等。 image

looly commented 3 weeks ago

@itflash 看下这个:

https://github.com/dromara/hutool/issues/1696