title: PHPExcel Check if sheet exists
body: <p>I am using phpExcel, and I can't find anything to check if a sheet exists. What I would like to accomplish is something like this:</p>
  
  <pre><code>if(!$excel-&gt;sheetExists(1)){
      $excel-&gt;createSheet(1);
      $sheet = $excel-&gt;setSheet(1);
  }
  // Do some stuff with the sheet
  </code></pre>
  
  <p>So. My question: How can I check if a sheet exists?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Would this work?</p>
  
  <pre><code>try{
      $sheet = $this-&gt;excel-&gt;setActiveSheetIndex(1);
  }catch(Exception $e){
      $excel-&gt;createSheet(1);
      $sheet = $excel-&gt;setActiveSheetIndex(1);
  }
  </code></pre>