I am currently using Apache POI for Java to set formulas in cells.
But after I run the program and open the Excel file that I created and processed, the cells with t
I was having the similar problem and "SUM(B4:B20)"
does not work for me directly as the sheet was generated dynamically. The problem was with the cell reference.
On the basis of https://stackoverflow.com/a/2339262/2437655 and https://stackoverflow.com/a/33098060/2437655 I was able to generate the actual formula. e.g.
val totalProductQtyPerUserCell = userDetailsRow.createCell(products.size + 1)
totalProductQtyPerUserCell.cellType = HSSFCell.CELL_TYPE_FORMULA
totalProductQtyPerUserCell.cellFormula = "SUM(${CellReference.convertNumToColString(1)}${totalProductQtyPerUserCell.row.rowNum + 1}:${CellReference.convertNumToColString(products.size)}${totalProductQtyPerUserCell.row.rowNum + 1})"
Hope that help.