我有一张6列和50k行的表格。我想复制一行n次。 现在我这样做:
for (int i=0; i<=excel_max_row; i++) {
row = sheet3.createRow((short) i);
cell = row.createCell(0);
cell.setCellFormula("IFERROR(LOOKUP(Template!A"+(i+2)+",'Dropdown-Values'!A:A,'Dropdown-Values'!B:B),\"\")");
cell = row.createCell(1);
cell.setCellFormula("IF(Template!B"+(i+2)+"=0,\"\",Template!B"+(i+2)+")");
cell = row.createCell(2);
cell.setCellFormula("IFERROR(LOOKUP(Template!C"+(i+2)+",'Dropdown-Values'!C:C,'Dropdown-Values'!D:D),\"\")");
cell = row.createCell(3);
cell.setCellFormula("IFERROR(LOOKUP(Template!D"+(i+2)+",'Dropdown-Values'!E:E,'Dropdown-Values'!F:F),\"\")");
cell = row.createCell(4);
cell.setCellFormula("IFERROR(LOOKUP(Template!E"+(i+2)+",'Dropdown-Values'!E:E,'Dropdown-Values'!F:F),\"\")");
cell = row.createCell(5);
cell.setCellFormula("IF(Template!F"+(i+2)+"=0,\"\",Template!F"+(i+2)+")");
}
XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
它有效,但速度很慢,因为excel_max_row
最高可达50k。有没有办法快速复制一行n次与所有forumals?
非常感谢
答案 0 :(得分:1)
我在用户打开文件时评估所有公式:
wb.setForceFormulaRecalculation(true);