[alibaba/easyexcel]根据模板写入,生成的文件 表头会有重复

2024-05-10 580 views
8
  @Getter
@Setter
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class Question1 {

    @ExcelProperty("问题1")
    private String l1;
    @ExcelProperty("问题2")
    private String l2;
    @ExcelProperty("问题3")
    private String l3;

}

 private static void write_template_multi_one() {

        String pathName = "D:/dmslog/test_w.xlsx";
        String wriPathName = "D:/dmslog/test_template_mul_one.xlsx";
        List list = new ArrayList();
        list.add(new Question1("1", "1", "1"));
        list.add(new Question1("2", "1", "1"));
        list.add(new Question1("3", "1", "1"));

        ExcelWriter build = EasyExcel
                .write(pathName, Question1.class)
                .withTemplate(wriPathName)
//                .sheet()
                .build();

        WriteSheet build1 = EasyExcel.writerSheet(0).build();
        WriteSheet build2 = EasyExcel.writerSheet(1).build();
        build.write(list,build1);
        build.write(list,build2);
//        build.fill(new Question1("1", "1", "1"),build1);
        build.finish();
    }

异常提示 请提供完整的异常提示,记住是全部异常! 建议描述

回答

9

设置ignoreHead=true

0

ignoreHead=true在哪里设置,我写了好几个地方都没有这个属性