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

增加注解@ExcelSubData 来导出有层次结构的数据 #3263

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cao2068959
Copy link

导出excel的时候可以在对象中添加 @ExcelSubData 来导出 tree 结构的数据如:

@Data
public class TreeDemoData {

    @ExcelProperty("字符串标题")
    private String string;
    @ExcelProperty("日期标题")
    private Date date;
    @ExcelProperty("数字标题")
    private Double doubleData;
    // 标注 sub中的数据将使用 group的方式导出,同时不同层级之间使用 “灰色",”蓝色“ 来区分
    @ExcelSubData(fillForegroundColors = {IndexedColors.GREY_25_PERCENT, IndexedColors.LIGHT_TURQUOISE})
    private List<TreeDemoData> sub = new ArrayList<>();
}

如:建立数据结构如下

  • 学校1
    • 年级1
      • 班级 1
    • 年级1
      • 班级 1

导出数据如下所示
image

可以参考单元测试
com.alibaba.easyexcel.test.demo.write.WriteTest#treeWrite

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

Successfully merging this pull request may close these issues.

None yet

1 participant