title: PHPSpreadsheet generates an error "Wrong number of arguments for INDEX() function: 5 given, between 1 and 4 expected"
body: <p>I tried to enter the following code in my excel formula bar directly
  <code>=INDEX($E$4:$E$132,AGGREGATE(15,6,ROW($1:$30) / ($J$4:$J$132=M4), COUNTIF($M$4:M4, M4)))</code> and works perfectly fine (the left column on the pic below).</p>
  
  <p><img src="https://i.imgur.com/OsCJQFN.png" alt="pic" title="Excel Raw">
  <br></p>
  
  <p>But if I'm using my web application to generate an excel report file (PHP, using CodeIgniter and Laravel). It displays an error "<strong>'Wrong number of arguments for INDEX() function: 5 given, between 1 and 4 expected'</strong>"</p>
  
  <p>Here's my sample code snippet:</p>
  
  <pre><code>$code = "=INDEX(\$E\$4:\$E\$$occurance, AGGREGATE(15,6,ROW(\$1:\$$occurance) / (\$J\$4:\$J\$$occurance=M$top_cell), COUNTIF(\$M\$4:M$top_cell, M$top_cell)))";
  $ews2-&gt;setCellValue("L$top_cell", $code);
  </code></pre>
  
  <p>I also have tried to use the <strong>setValueExplicit</strong> method but causes the excel file to NOT precalculate the code, it reads the code as a <em>string</em></p>
  
  <pre><code>$ews2-&gt;setCellValueExplicit("L$top_cell", $code, DataType::TYPE_STRING);
  </code></pre>
  
  <p><strong>NOTE</strong> TYPE_STRING is provided because if TYPE_FORMULA is also used, the same output mentioned at the top occurs</p>
  
  <p>Here's what it looks like using the <strong>setCellValueExplicit</strong></p>
  
  <p><img src="https://i.imgur.com/LQ7m3Rs.png" alt="Precoded from PHP" title="Precoded from PHP">
  May I know the right solution or quick fix for this? Thank you very much in advance!</p>