title: How do I remove column in PHPExcel
body: <p>I want to remove highlighted column from my Excel sheet. Please check the code:</p>
  
  <pre><code>// generate report
  if($genReport) {
      include_once("../../../includes/dbcon/mysql-crm.php");
  
      //01.generate first date and last day
      $month_end = date('d', strtotime($toDate));
      $month_first = date('d', strtotime($fromDate));
  
      include("../../../includes/addons/php-excel-gen/PHPExcel.php");
      $objPHPExcel = new PHPExcel();
      $objPHPExcel-&gt;getProperties()-&gt;setCreator("Shanka Nuwan")
                           -&gt;setLastModifiedBy("Shanka Nuwan")
                           -&gt;setTitle("Call Center Report - ".$reportNamePart)
                           -&gt;setSubject("Call Center Report - ".$reportNamePart)
                           -&gt;setDescription("Call Center Report - ".$reportNamePart)
                           -&gt;setKeywords("Call Center Report - ".$reportNamePart)
                           -&gt;setCategory("Call Center");
      $objPHPExcel-&gt;setActiveSheetIndex(0);
      $objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells('A1:C1');
      $objPHPExcel-&gt;getDefaultStyle()-&gt;getFont()-&gt;setSize(15);
  
      $objRichText = new PHPExcel_RichText();
      $objPayable = $objRichText-&gt;createTextRun($reportNamePart);
      $objPayable-&gt;getFont()-&gt;setBold(true);
      $objPayable-&gt;getFont()-&gt;setSize(14); 
      $objPayable-&gt;getFont()-&gt;setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );
      $objPHPExcel-&gt;getActiveSheet()-&gt;getCell('A1')-&gt;setValue($objRichText);
  
      $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue('A2', 'Date');
      $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue('A3', 'SHOWROOM');
  
      $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension('A')-&gt;setAutoSize(true);
      $objPHPExcel-&gt;getDefaultStyle()-&gt;getFont()-&gt;setSize(10); 
  
          //add allboder style
          $BStyle = array(
              'borders' =&gt; array(
                'allborders' =&gt; array(
                  'style' =&gt; PHPExcel_Style_Border::BORDER_THIN
                )
              )
            );
          $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A2:BI105')-&gt;applyFromArray($BStyle);
  
      $row = 4;
  
      // generate report column
      $column = 'B';
      $column2 = 'C';
      $x = $month_first;
  
      for(;$x&lt;=$month_end;) {
  
          $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.'3', 'Enquiry');
          $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.'2', $x);
          $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension('B')-&gt;setVisible(false);
  
          $x++;
  
          if($x&lt;=$month_end) {
              $column2++;
              $column = $column2;
              $column2++;
          }
      }
  
      // add total column after dates
      $column2++;
      $column = $column2;
      $column2++;
      //$objPHPExcel-&gt;getActiveSheet()-&gt;mergeCells($column.'2:'.$column2.'2');
      $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue('A105', 'Total');
      $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.'3', 'Enquiries Total');
      /*
      $styleArray = array(
      'font'  =&gt; array(
          'bold'  =&gt; true,
          'color' =&gt; array('rgb' =&gt; 'FF0000'),
          'size'  =&gt; 15,
          'name'  =&gt; 'Verdana'
      ));
      */
      $styleArray = array('font'  =&gt; array('color' =&gt; array('rgb' =&gt; 'FF0000')));
      //$objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column.'2')-&gt;applyFromArray($styleArray);
      //$objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column.'3')-&gt;applyFromArray($styleArray);
      $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column2.'3')-&gt;applyFromArray($styleArray);
  
  
      //report name letter style
      $objPHPExcel-&gt;getDefaultStyle()-&gt;getFont()-&gt;setSize(11); 
      $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A2:'.$column2.'2')-&gt;getFont()-&gt;setBold(true);
  
      $style = array(
          'alignment' =&gt; array(
              'horizontal' =&gt; PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
              )
          );
      //align report headers
      $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A2:'.$column2.'2')-&gt;applyFromArray($style);
      $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A3:'.$column2.'3')-&gt;applyFromArray($style);
  
      //load location
      $get_sql ="SELECT
      showrooms.showroom_id,
      showrooms.showroom_code,
      showrooms.showroom_name,
      showrooms.showroom_address,
      showrooms.address_city,
      showrooms.manager_name,
      showrooms.manager_mobile,
      showrooms.manager_id,
      showrooms.shop_email,
      showrooms.shop_phone,
      showrooms.shop_fax,
      showrooms.showroom_type,
      showrooms.added_date,
      showrooms.last_update,
      showrooms.added_by,
      showrooms.status_id
      FROM
      showrooms
      INNER JOIN showroom_type ON showrooms.showroom_type = showroom_type.showroom_type_id
      WHERE showrooms.showroom_id &gt; '0' and  
      showrooms.showroom_type = '1' AND 
      showrooms.status_id = '1'
      ORDER BY
      showrooms.showroom_name ASC";
  
      $get_showroom = $db-&gt;get_results($get_sql);
      if($db-&gt;num_rows&gt;0){
          $row = 4;
          foreach($get_showroom as $row_showroom){    
              $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue('A'.$row , $row_showroom-&gt;showroom_name);
              //get showroom id
              $showroom_email= explode('@',$row_showroom-&gt;shop_email);
              $showroom_id = $showroom_email[0];
              //check showroom already intract with showroom task
              $sso_user = $db-&gt;get_row("SELECT users.user_id FROM users WHERE users.login_name = '".$showroom_id."'");
              $total_inqury = 0;
              if($db-&gt;num_rows == 1){
                  $user_id =  $sso_user-&gt;user_id;
                  //date check
                  $column = 'B';
                  $column2 = 'C';
                  $day = $month_first;
                  for(;$day&lt;=$month_end;){
                      $byear = date('Y',strtotime($fromDate));
                      $month = date('m',strtotime($fromDate));
  
                      $check_date = strtotime($byear.'-'.$month.'-'.$day);
                      $user_login = $db-&gt;get_row("SELECT 
                                                      Count(sys_id) AS locount 
                                                      FROM 
                                                          sys_user_login 
                                                      WHERE 
                                                          user_id = '".$user_id."' 
                                                      AND log_date = '".date('Y-m-d',$check_date)."'");//$db-&gt;debug();
                      if($db-&gt;num_rows == 1){
                          if($user_login-&gt;locount &gt; 0){
                              $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column.$row , '');
                              $styleArray = array('font'  =&gt; array('color' =&gt; array('rgb' =&gt; 'FF0000')));
                              $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column.$row)-&gt;applyFromArray($styleArray);
                              //$total_login++;
  
                              //back groud color for cell
                              $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column2.$row)-&gt;applyFromArray(
                                                                      array(
                                                                          'fill' =&gt; array(
                                                                              'type' =&gt; PHPExcel_Style_Fill::FILL_SOLID,
                                                                              'color' =&gt; array('rgb' =&gt; 'FFFF00')
                                                                          )
                                                                      )
                                                                  );
                          }else{
                              //$objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column.$row , '');
                          }
                      }else{
                          //$objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column.$row , '');
                      }
  
                      //count inquery
                      $inquery_day = $dbCrm-&gt;get_row("SELECT
                                                      Count(customers.cu_id) AS inq_day 
                                                      FROM
                                                      customers
                                                      WHERE
                                                      customers.added_by = '".$user_id."' AND
                                                      customers.added_date LIKE '".date('Y-m-d',$check_date)."%'");//$db-&gt;debug();
                      if($dbCrm-&gt;num_rows == 1){
                          if($inquery_day-&gt;inq_day &gt; 0){
                              $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.$row ,$inquery_day-&gt;inq_day);
                              $total_inqury += $inquery_day-&gt;inq_day;
                          }else{
                              $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.$row , '0');
                          }
                      }else{
                          $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.$row , '0');
                      }
  
                      $day++;
                      if($day&lt;=$month_end){
                          $column2++;
                          $column = $column2;
                          $column2++;
                      }
                  }
                  $column2++;
                  $column = $column2;
                  $column2++;
  
                  $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue($column2.$row, $total_inqury);                               
                                  $objPHPExcel-&gt;getActiveSheet()
                                              -&gt;setCellValue(
                                                  'C105',
                                                  '=SUM(A10:E9)'
                                              );
                  $styleArray = array('font'  =&gt; array('color' =&gt; array('rgb' =&gt; 'FF0000')));
                  $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle($column2.$row)-&gt;applyFromArray($styleArray);
                  $total_inqury = 0;
              }
              $row++;
          }
      }
  
  
      //genarate report data
      header('Content-Type: application/vnd.ms-excel');
      header('Content-Disposition: attachment;filename="showroom-task-report-'.$byear.'-'.strtolower(date('F', mktime(0, 0, 0, $month, 10))).'.xls"');
      header('Cache-Control: max-age=0');
  
      $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
      $objWriter-&gt;save('php://output');
  }
  ?&gt;
  </code></pre>
  
  <p>below excel out will generate from the above coding. I tried lot of hours to figure out how to get ride of it. Still can't find the solution. </p>
  
  <p><a href="https://i.stack.imgur.com/DiUrC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DiUrC.png" alt="excel file"></a></p>