task-26: 模板 workbook 大行数下的样式、图片和工作表兼容测试

writeWorkbook(模板路径)改为返回实际写入行数,与 streaming 路径一致;
新增 1000/5000 行规模兼容测试:模板表头样式保留、同 URL 图片按 pictureIndex 去重复用、
5 工作表顺序名称保持模板语义、失败行兜底 URL 文本不中断整表。
全量测试 556 通过。
This commit is contained in:
2026-08-29 18:55:01 +08:00
parent 6594e1f5d7
commit 8ea4d2f502
2 changed files with 325 additions and 1 deletions
@@ -83,7 +83,7 @@ public class ShopDataCrawlExcelAssemblyService {
imageEmbedder.prefetch(prefetchBudget().boundedUrls(imageUrls(rowsByCountry)), imageCache);
}
public void writeWorkbook(File outputXlsx, List<ShopDataCrawlResultItemVo> items) {
public int writeWorkbook(File outputXlsx, List<ShopDataCrawlResultItemVo> items) {
try (InputStream input = new ClassPathResource(TEMPLATE).getInputStream();
XSSFWorkbook workbook = new XSSFWorkbook(input);
FileOutputStream output = new FileOutputStream(outputXlsx)) {
@@ -96,6 +96,7 @@ public class ShopDataCrawlExcelAssemblyService {
writeSheet(workbook, workbook.getSheetAt(i), rowsByCountry.get(COUNTRIES.get(i)), imageCache, pictureIndexes);
}
workbook.write(output);
return rowsByCountry.values().stream().mapToInt(List::size).sum();
} catch (BusinessException ex) {
throw ex;
} catch (Exception ex) {