title: Excel formula gives error when write using Apache-poi library in Java
body: <p>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".</p>
  
  <p>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:</p>
  
  <pre><code>SUMPRODUCT(SUBTOTAL(9,OFFSET(B2:B10,ROW(B2:B10)-(ROW(B2)),0,1)),(--(A2:A10="Recived")))
  </code></pre>
  
  <p>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.</p>
  
  <p>I want the value for the formula to be displayed every time I open the Excel file.</p>
  
  <p>Below is Java code </p>
  
  <pre><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\")))");
  </code></pre>