-
Notifications
You must be signed in to change notification settings - Fork 325
Excel default export
The default export method is to export List<bean>
in a common way, which is suitable for small data volume scenarios, such as large data volume - 100000 +. It is recommended to use DefaultStreamExcelBuilder to avoid excessive memory consumption.
The default is to export version 3.0.0.rc and its subsequent versions,the bottom layer is
DefaultStreamExcelBuilder
.
The following notes are required for export
- @ExcelModel(includeAllField,excludeParent,workbookType,sheetName,useFieldNameAsTitle,defaultValue)(Optional. It is used for global setting. Generally, only sheetname is needed)
- @IgnoreColumn(Optional to exclude fields that do not need to be exported)
- @ExcelColumn(title,order,format,groups,defaultValue,style)
For details of corresponding notes, please refer to notes
The default calculated width and background color of zebra crossing are exported by default. If the above styles are not needed, please call the
nostyle()
method
Attachment export example:
@GetMapping("/default/excel/example")
public void defaultBuild(HttpServletResponse response) throws Exception {
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
AttachmentExportUtil.export(workbook, "艺术生信息", response);
}
Attachment encryption export example:
@GetMapping("/default/excel/example")
public void defaultBuild(HttpServletResponse response) throws Exception {
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
AttachmentExportUtil.encryptExport(workbook, "艺术生信息", response,"123456");
}
Sample file export:
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
FileExportUtil.export(workbook, new File("/User/demo.xlsx"));
Sample file encryption export:
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
FileExportUtil.encryptExport(workbook, new File("/User/demo.xlsx"),"123456");
Data acquisition:
private List<ArtCrowd> getDataList() {
List<ArtCrowd> dataList = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
ArtCrowd artCrowd = new ArtCrowd();
artCrowd.setName("李四");
artCrowd.setAge(18);
artCrowd.setGender("Woman");
artCrowd.setPaintingLevel("一级证书");
artCrowd.setDance(true);
artCrowd.setAssessmentTime(LocalDateTime.now());
artCrowd.setHobby("钓鱼");
dataList.add(artCrowd);
}
return dataList;
}
@ExcelModel(sheetName = "艺术生")
public class ArtCrowd {
@ExcelColumn(order = 0, title = "姓名")
private String name;
@ExcelColumn(order = 1, title = "年龄")
private Integer age;
@ExcelColumn(order = 2, title = "性别")
private String gender;
@ExcelColumn(order = 3,title = "绘画等级")
private String paintingLevel;
@ExcelColumn(order = 4, title = "是否会跳舞")
private boolean dance;
@ExcelColumn(order = 5, title = "考核时间", format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime assessmentTime;
@IgnoreColumn
private String hobby;
}
-
Overview
概述 -
FAQ
常见问题 -
Dependency adding
依赖添加 -
Excel/Csv import
Excel/Csv导入 - 一对多导入
-
Excel default export
默认导出 -
Excel streaming export
流式导出 -
Dynamic export
动态导出 -
Excel template build
模板构建 -
CSV export
csv导出 -
Multiple sheet import
多sheet导入 -
Multiple sheet export
多sheet导出 - 聚合列&聚合导出
-
Custom style
自定义样式 -
Multilevel header
多级表头 -
Wrap within cell
单元格内换行 -
Image export
图片导出 -
Image import
图片导入 -
Hyperlink
链接 - 读取链接
-
Template row height setting
模板行高度设置 -
Drop-down-list
下拉列表 -
Custom convert
写入自定义转化 -
Formula usage
公式使用 -
Template cell setting
单元格设置 -
Header freeze
区域冻结 - 提示
-
Style support
样式支持 - 添加水印
- 按列读取
- 单元格斜线绘制
- 设置批注
- 版本日志