title: PHPExcel - set cell values form array
body: <p>I am pulling array data from my database for specific id and I defined cells where that values need to be stored for export.</p>
  
  <p>I am calling it from my service via function and I can't find any example of how to set specific data in specific cells.</p>
  
  <p>My code:</p>
  
  <p>From my service..</p>
  
  <pre><code> public function getExport($account)
  {
  
      $all = $this-&gt;em-&gt;getRepository('AppBundle:App')-&gt;findBy([
          'account' =&gt; $account
      ]);
  
      $rows = [];
  
      $rows[] = [
          "client",
          "payer_name",
          "payer_info"
      ];
  
      foreach ($all as $row) {
          $client = $row-&gt;getAccount();
          $payerName = $row-&gt;getName();
          $payerInfo = $row-&gt;getInfo();
  
          if (empty($rows[$client])) {
              $rows[] = [
                  $client,
                  $payerName,
                  $payerInfo
              ];
          } else {
              $rows[$client][1][] = $payerInfo;
          }
        };
  
      return $rows;
  }
  </code></pre>
  
  <p>And in controller I prepared logic for export..</p>
  
  <pre><code>    public function downloadInvoice($account) {
  
  $phpExcelObject = $this-&gt;get('phpexcel')-&gt;createPHPExcelObject($webPath);
  
      $rows= $this-&gt;get('app')-&gt;getExport($account);
  
      $phpExcelObject-&gt;setActiveSheetIndex(0)
      -&gt;setCellValue('A17', 'Here need to go client')
      -&gt;setCellValue('E17', 'Here needs to go payer info etc...')
  
      $writer = $this-&gt;get('phpexcel')-&gt;createWriter($phpExcelObject, 'Excel2007');
      $response = $this-&gt;get('phpexcel')-&gt;createStreamedResponse($writer);
      $dispositionHeader = $response-&gt;headers-&gt;makeDisposition(
          ResponseHeaderBag::DISPOSITION_ATTACHMENT,
          'the-file.xlsx'
      );
      $response-&gt;headers-&gt;set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
      $response-&gt;headers-&gt;set('Cache-Control', 'maxage=1');
      $response-&gt;headers-&gt;set('Content-Disposition', $dispositionHeader);
  
      return $response;
  
  }
  </code></pre>