title: set column name and column width using PHPExcel in codeigniter
body: <p>Good day, I'm struggling to find out how to set a column name before each value in PHPExcel with codeigniter. Since my PHPExcel works to get the value from database, my problem is how to set a column name of each column.</p>
  
  <p>current output image: </p>
  
  <p><a href="https://i.stack.imgur.com/tOEMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tOEMZ.png" alt="enter image description here"></a></p>
  
  <p>My code:</p>
  
  <pre><code>       //load our new PHPExcel library
          $this-&gt;load-&gt;library('excel');
          //activate worksheet number 1
          $this-&gt;excel-&gt;setActiveSheetIndex(0);
          //name the worksheet
          $this-&gt;excel-&gt;getActiveSheet()-&gt;setTitle('Users list');
  
          // Trying to set a column name
          $this-&gt;excel-&gt;getActiveSheet()-&gt;SetCellValue('A1', 'ID');
          $this-&gt;excel-&gt;getActiveSheet()-&gt;SetCellValue('B1', 'FIRST NAME');
          $this-&gt;excel-&gt;getActiveSheet()-&gt;SetCellValue('C1', 'LAST NAME');
          $this-&gt;excel-&gt;getActiveSheet()-&gt;SetCellValue('D1', 'EMAIL');
          $this-&gt;excel-&gt;getActiveSheet()-&gt;SetCellValue('E1', 'TIME');
          // get all users in array formate
          $users = $this-&gt;User_info-&gt;getallusers();
  
  
          // read data to active sheet
          $this-&gt;excel-&gt;getActiveSheet()-&gt;fromArray($users);
  
          $filename='just_some_random_name.xlsx'; //save our workbook as this file name
  
          header('Content-Type: application/vnd.ms-excel'); //mime type
  
          header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
  
          header('Cache-Control: max-age=0'); //no cache
  
          //save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
          //if you want to save it as .XLSX Excel 2007 format
  
          $objWriter = PHPExcel_IOFactory::createWriter($this-&gt;excel, 'Excel2007');
  
          //force user to download the Excel file without writing it to server's HD
                  ob_end_clean();
          $objWriter-&gt;save('php://output');
  </code></pre>
  
  <p>I want the output look like this</p>
  
  <p><a href="https://i.stack.imgur.com/sRqQF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sRqQF.png" alt="enter image description here"></a></p>
  
  <p>One more problem that I've seen is the width of every column. can you fix it also for me? </p>