>我在 excel 工作表中有一个公式,格式如下
{=SUM(IF(C3:C65536=F11,B3:B65536))}
这是一个公式数组。如何使用Apache POI API在Java中实现这一点?
我在java中做到了这一点
cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
cell.setCellFormula("SUM(IF(C3:C65536=F"+totalCtr+",B3:B65536))");
其中 totalCtr 是一个 int 变量,从 0... n
迭代并且是公式中"F"的一部分。所以我可以从一个细胞转到下一个细胞。
较
新版本的POI支持数组公式
见 https://poi.apache.org/spreadsheet/formula.html
Array Formulas: via Sheet.setArrayFormula() and Sheet.removeArrayFormula()