title: PhpSpreadsheet with large data
body: <p>i have a multidimensional array with 3070 Values</p>
  
  <pre><code>$tbl= array(
    array(
      "KDNR" =&gt; 1,
      "GESCHL" =&gt; "test",
      "TITEL" =&gt; "test",
      "VORNAME" =&gt; "test",
      "FAMNAME" =&gt; "test",
      "PLZ" =&gt; "test",
      "ORT" =&gt; "test",
      "STRASSE" =&gt; "test",
      "EMAIL" =&gt; "test",
      "PRIVTEL" =&gt; "test"
    ),
    "KDNR" =&gt; 2,
      "GESCHL" =&gt; "test2",
      "TITEL" =&gt; "test2",
      "VORNAME" =&gt; "test2",
      "FAMNAME" =&gt; "test2",
      "PLZ" =&gt; "test2",
      "ORT" =&gt; "test2",
      "STRASSE" =&gt; "test2",
      "EMAIL" =&gt; "test2",
      "PRIVTEL" =&gt; "test2"
    ),
    etc...
  );
  </code></pre>
  
  <p>I want to write the array tbl with 3070 arrays to a xlsx file.
  I use for this PhpSpreadsheet.</p>
  
  <p>This is my php code:</p>
  
  <pre><code>&lt;?php
  //call the autoload
  require($_SERVER['DOCUMENT_ROOT'].'/src/phpspreadsheet/vendor/autoload.php');
  //load phpspreadsheet class using namespaces
  use PhpOffice\PhpSpreadsheet\Spreadsheet;
  //call iofactory instead of xlsx writer
  use PhpOffice\PhpSpreadsheet\Aligment;
  use PhpOffice\PhpSpreadsheet\Fill;
  use PhpOffice\PhpSpreadsheet\IOFactory;
  
  
  //load from xlsx template
  $reader = IOFactory::createReader('Xlsx');
  $spreadsheet = $reader-&gt;load($_SERVER['DOCUMENT_ROOT']. '/src/ExcelVorlagen/polbezirk_template.xlsx');
  
  //loop the data
  $contentStartRow = 3;
  $currentContenRow = 3;
  
  //set coulm dimension to auto size
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('A')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('B')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('C')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('D')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('E')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('F')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('G')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('H')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('I')
              -&gt;setAutoSize(true);
  $spreadsheet-&gt;getActiveSheet()
              -&gt;getColumnDimension('J')
              -&gt;setAutoSize(true);
  
  xdebug_break();
  foreach($tbl as $item){
      //insert a row after current row (before current row + 1)
      $spreadsheet-&gt;getActiveSheet()-&gt;insertNewRowBefore($currentContenRow + 1,1);
  
      //fill the cell with Data
      $spreadsheet-&gt;getActiveSheet()
          -&gt;setCellValue('A'.$currentContenRow, $item['KDNR'])
          -&gt;setCellValue('B'.$currentContenRow, $item['GESCHL'])
          -&gt;setCellValue('C'.$currentContenRow, $item['TITEL'])
          -&gt;setCellValue('D'.$currentContenRow, $item['VORNAME'])
          -&gt;setCellValue('E'.$currentContenRow, $item['FAMNAME'])
          -&gt;setCellValue('F'.$currentContenRow, $item['PLZ'])
          -&gt;setCellValue('G'.$currentContenRow, $item['ORT'])
          -&gt;setCellValue('H'.$currentContenRow, $item['STRASSE'])
          -&gt;setCellValue('I'.$currentContenRow, $item['EMAIL'])
          -&gt;setCellValue('J'.$currentContenRow, $item['PRIVTEL']);
      //increment the current row number
      $currentContenRow++;                 
  }
  
  //remove last empty rows
  //$spreadsheet-&gt;getActiveSheet()-&gt;removeRow($currentContenRow,2); 
  
  //set the header first, so the result will be treated as an xlsx file
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  
  //make it an attachment so we can define filename
  header('Content-Disposition: attachment;filename="result.xlsx"');
  
  //create IOFactory object
  $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
  //save int php output
  $writer-&gt;save('php://output');
  
  </code></pre>
  
  <p>when i execute the code it takes 49 minutes to create the xlsx file, this it to long for only 3070 rows.
  Is there a faster way? Or have i a bottleneck in my code?</p>
  
  <p>hope you guys can help me</p>
  
  <p>best best regards</p>