https://github.com/c-rainstorm/common-utils
项目中可以使用的通用工具
https://github.com/c-rainstorm/common-utils
Last synced: 3 months ago
JSON representation
项目中可以使用的通用工具
- Host: GitHub
- URL: https://github.com/c-rainstorm/common-utils
- Owner: c-rainstorm
- License: mit
- Created: 2019-08-28T01:34:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T17:36:30.000Z (over 3 years ago)
- Last Synced: 2025-04-04T10:43:57.052Z (9 months ago)
- Language: Java
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# common-utils
项目中可以使用的通用工具
## 报表导出工具
```java
private void doExport(int sizePreExport, int totalSize, String sheetNamePrefix, int sheetSize, Function> supplier) throws Exception {
File exportFile = Paths.get(EXPORT_DIR, sheetNamePrefix + "-" +
DateTimeFormatterUtil.get(DateTimeFormatterUtil.YYYYMMDDHHMMSS).format(LocalDateTime.now())
+ ".xlsx").toFile();
log.info("file name:" + exportFile.getAbsolutePath());
try (ExportService exportService = new XLSXExportService<>(AllInOneClass.class, exportFile)) {
long total = 0;
for (int i = 0; i < totalSize; i += sizePreExport) {
List dataList = supplier.apply(sizePreExport);
long start = System.currentTimeMillis();
exportService.append(dataList);
total += (System.currentTimeMillis() - start);
log.info("导出 {} 条数据耗时 {}ms", i + sizePreExport, total);
}
}
}
```