github 源码地址
【注】该需求的实现位于MultipartFileDownloadController下
源码
代码
@GetMapping("/mulDownload")
public void mulDownloadFile(HttpServletResponse response) throws InterruptedException {
//获取所有表
List<String> tables = MetaUtil.getTables(DbUtil.getDs());
//创建excel读写
ExcelWriter bigWriter = ExcelUtil.getBigWriter(60000);
//设置日期
short i = bigWriter.getWorkbook().createDataFormat().getFormat("yyyy年MM月dd日");
bigWriter.getStyleSet().getCellStyleForDate().setDataFormat(i);
//设置字体
Font font = bigWriter.createFont();
font.setBold(true);
font.setFontName("Microsoft YaHei");
font.setFontHeightInPoints((short) 14);
bigWriter.getStyleSet().getHeadCellStyle().setFont(font);
//创建索引
createCatalog(bigWriter, tables);
CountDownLatch latch = new CountDownLatch(tables.size());
ThreadUtil.execAsync(()->{
for (String tableName : tables) {
try {
Table table = MetaUtil.getTableMeta(DbUtil.getDs(), tableName);
//获取当前表的所有记录
List<Entity> allRecords = this.findAllRecords(table.getTableName());
//获取表结构所有列信息
Collection<Column> columns = table.getColumns();
HashMap<String, String> map = new HashMap