I have requirement to write data to excel file which I have achieved. And another requirement is to include piece cell in the summation if status cell of same row is "Recived".
And the summation should be done for visible cells only. I have 2 column like "Status"(Column A2:A10) and "piece" (B2:B10) now I have put the formula in my java class using apache-poi library:
SUMPRODUCT(SUBTOTAL(9,OFFSET(B2:B10,ROW(B2:B10)-(ROW(B2)),0,1)),(--(A2:A10="Recived")))
After executing the Java code it writes the file successfully but when I open the file it shows the formula cell as #VALUE!. When I go to formula bar and press enter then the value for the formula comes.
I want the value for the formula to be displayed every time I open the Excel file.
Below is Java code
cell.setCellType(Cell.CELL_TYPE_FORMULA);
cell.setCellFormula("SUMPRODUCT(SUBTOTAL(9,OFFSET(B2:B10,ROW(B2:B10)-(ROW(B2)),0,1)),(--(A2:A10=\"Recived\")))");