title: PHPExcel - colspan the subject name
body: <ul>
  <li><p>Table name: <strong>subject</strong><br />
  <a href="https://i.stack.imgur.com/Ne6Yy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ne6Yy.png" alt="enter image description here"></a></p></li>
  <li><p>My Expected output<br />
  <a href="https://i.stack.imgur.com/Z0mKB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z0mKB.png" alt="enter image description here"></a></p></li>
  <li><p>My code<br /></p>
  
  <pre><code>&lt;?php
      //dbconnection
  
      $q = "SELECT name FROM subject";
      $r = mysqli_query($dbc, $q);
  
      while($row = mysqli_fetch_array($r, MYSQLI_ASSOC))
      {
          $name[] = $row['name'];
      }
  
      $objPHPExcel = new PHPExcel();
      $objPHPExcel-&gt;setActiveSheetIndex(0);
  
      $headers = array('School Name');
      $objPHPExcel-&gt;getActiveSheet()-&gt;fromArray($headers, null, 'A1');
      $objPHPExcel-&gt;getActiveSheet()-&gt;fromArray($name, null, 'B1');
  
      $objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells('B1:C1');
      $objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells('D1:E1');
      $objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells('F1:G1');
      $objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells('H1:I1');
  ?&gt;
  </code></pre></li>
  <li><p>I want to set colspan = 2 for each subject. I don't want to write 4 individual lines of code. I try with for loop as below:</p>
  
  <pre><code>$objWorksheet = $objPHPExcel-&gt;getActiveSheet();
  
  $row = 1;
  $highestColumn = $objWorksheet -&gt; getHighestColumn();
  $highestColumn++;
  
  for($column = 'A'; $column != $highestColumn; $column++)
  {
      if($column &lt;= 'C')
      {
          //[HERE]
      }
  }
  </code></pre></li>
  <li><p>After I write the for loop, I am stuck. I have no ideas on how to control the column name and set the colspan. Can someone help me?</p></li>
  </ul>