title: PHP Fill with values an existing .xlsb file with data from Oracle
body: <p>I want to write into my .xlsb excel file which name is the number of the day.<br>
  For exemple the name of the file for yesterday is <code>23.xlsb</code>.  </p>
  
  <p>Initial the name of the file is "Template.xlsb" and the location is different. As you can see this file it's copied and renamed in a new location. In this file I have a lot of macros and vba codes and that's why I don't want to create a new Excel file.</p>
  
  <p>At the end, the link for this Excel file is in this variable <code>$renamed_link</code>.<br>
  <code>$renamed_link = C:\Documents and Settings\Administrator\Desktop\Rezultate DIDU\2017\Apr\23.xlsb</code>.</p>
  
  <p>I want to fill the first worksheet, named "Parametri" with data from my sql query(<code>$parametri</code>).<br>
  The range from worksheet wich will be filled with data is from <code>A2</code> until <code>T and the total number of the rows</code>. The table have 20 columns.</p>
  
  <pre><code>&lt;?php
  require(realpath(dirname(__FILE__)."/PHPExcel-1.8/Classes/PHPExcel.php"));
  $sql_data = date('d.m.Y', strtotime('-1days'));
  
      $conn = oci_connect('USER', 'PASS', 'dark:1521/DAR');
      if (!$conn) {
          $e = oci_error();
          trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
      }
      Else {echo 'Connection successfully !';
      }
  $parametri = oci_parse($conn,"SELECT * FROM R0508UNITP WHERE TO_DATE('${sql_data}','DD.MM.YYYY') BETWEEN R0508UNITP.R0508VFROM AND R0508UNITP.R0508VTILL");
  
  oci_execute($parametri);
  
  echo "&lt;table border='1'&gt;\n";
  while ($row = oci_fetch_array($parametri, OCI_ASSOC+OCI_RETURN_NULLS)) {
  
  
  echo "&lt;tr&gt;\n";
  foreach ($row as $item) {
      echo "    &lt;td&gt;" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&amp;nbsp;") . "&lt;/td&gt;\n";
  }
      echo "&lt;/tr&gt;\n";
  }
  echo "&lt;/table&gt;\n";
  
  $day = date('j', strtotime('-1 days'));
  $month = date('M', strtotime('-1 days'));
  $year = date('Y', strtotime('-1 days'));
  
  
  $link = "C:\Documents and Settings\Administrator\Desktop\Rezultate DIDU\\${year}\\${month}";
  $template_link = 'C:\Documents and Settings\Administrator\Desktop\Rezultate DIDU\Template.xlsb';
  $destination_link = "C:\Documents and Settings\Administrator\Desktop\Rezultate DIDU\\${year}\\${month}".'\Template.xlsb';
  $renamed_link = "C:\Documents and Settings\Administrator\Desktop\Rezultate DIDU\\${year}\\${month}\\${day}".'.xlsb';
  
  
  if(!is_dir($link)) 
  {
  
  mkdir($link, 0777,true);
  
  }
  
  if(!file_exists($destination_link))
  {
      copy($template_link,$destination_link);
  
  } else {
  }
  
  rename($destination_link,$renamed_link);
  ?&gt;
  </code></pre>
  
  <p>Print screen of my php table(some of it).<br>
  This table I want to be in my excel file. 
  <a href="https://i.stack.imgur.com/g7wI3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g7wI3.png" alt="enter image description here"></a></p>