title: create new worksheet PHPExcel
body: <p>I'm trying to create another worksheet and everything works fine. But what I need now is to create 1 depending on a variable. For instance :</p>
  
  <p>I have two options one for validation and one for results.
  Everything is conditioned by a boolean variable called <code>$resultado</code>.</p>
  
  <p>I have my component in CakePHP</p>
  
  <pre><code>function ExcelCargaMasivaComponent() {
      $this-&gt;xls = new PHPExcel();
      $this-&gt;sheet = $this-&gt;xls-&gt;getActiveSheet();
      $this-&gt;sheet-&gt;setTitle("Worksheet");
      $this-&gt;sheet-&gt;getDefaultStyle()-&gt;getFont()-&gt;setName('Verdana');
      $this-&gt;xls-&gt;createSheet();
      $this-&gt;xls-&gt;setActiveSheetIndex(1);
      $this-&gt;validations = $this-&gt;xls-&gt;getActiveSheet();
      $this-&gt;validations-&gt;setTitle('Validations');
  }
  </code></pre>
  
  <p>Where this-> validations is the second worksheet. Now, I need this worksheet has a different name, and therefore I want other data encapsulated in a function. So my function generate wanted condition this way:</p>
  
  <pre><code>function ExcelCargaMasivaComponent() {
      $this-&gt;xls = new PHPExcel();
      $this-&gt;sheet = $this-&gt;xls-&gt;getActiveSheet();
      $this-&gt;sheet-&gt;setTitle("Worksheet");
      $this-&gt;sheet-&gt;getDefaultStyle()-&gt;getFont()-&gt;setName('Verdana');
      $this-&gt;xls-&gt;createSheet();
      $this-&gt;xls-&gt;setActiveSheetIndex(1);
  }
  
  function generate($title = 'Report', $headers = array(), $data = array(), $uid = false, $resultados = false){
      if($resultados){
         $this-&gt;validations = $this-&gt;xls-&gt;getActiveSheet();
         $this-&gt;validations-&gt;setTitle('Resultados');
      }else{
         $this-&gt;validations = $this-&gt;xls-&gt;getActiveSheet();
         $this-&gt;validations-&gt;setTitle('Validations');
      }
  }
  </code></pre>
  
  <p>I do this so that the second sheet has a different name and different data depending on the variable, but I could not get it to work. I only generates 1 sheet with the title depending on the variable, it's not what I want.</p>