title: Selecting a sheet using Laravel-Excel
body: <p>I'm using the very useful <a href="https://github.com/Maatwebsite/Laravel-Excel" rel="nofollow">https://github.com/Maatwebsite/Laravel-Excel</a> package.</p>
  
  <p>As I liked the idea of keeping my controllers clear of the excel import code, I'm loading the uploaded file using ExcelFile injections, see here: <a href="http://www.maatwebsite.nl/laravel-excel/docs/import#injection" rel="nofollow">http://www.maatwebsite.nl/laravel-excel/docs/import#injection</a></p>
  
  <p>This is my code for the ExcelFile Injection:</p>
  
  <p><strong>StudentImport.php</strong>
      
  
  <pre><code>namespace App\Excel;
  
  class StudentImport extends \Maatwebsite\Excel\Files\ExcelFile {
  
      public function getFile()
      {
          return \Input::file('student_file');
      }
  
      public function getFilters()
      {
          return [];
      }
  
  }
  </code></pre>
  
  <p>However, my problem is that I don't understand where I run methods like: <code>-&gt;selectSheets('mysheet')</code> when using this approach.</p>
  
  <p>My current work around is doing the following in my controller after using the ExcelFile injection to grab the file.</p>
  
  <p><strong>ExcelController.php</strong></p>
  
  <pre><code>public function import(StudentImportFormRequest $request, StudentImport $import)
  {
      $results = $import-&gt;get();
  
      foreach($results as $sheet) {
          $sheetTitle = $sheet-&gt;getTitle();
  
          if($sheetTitle === 'students') {
              foreach($sheet as $row) {
                  // do something
              }
          }
      }
  
  }
  </code></pre>
  
  <p>I believe I may need to extend the ExcelFile class and add a new method which will be a wrapper around the selectSheets() method or add it in to the loadFile() method somehow - this seems to be the place where the filters and settings are set up so I guess this is where you might add in a selection of a specific sheet?</p>
  
  <p>Also, I would like to know how to set certain columns to strings as they currently being read as numbers. Currently I have text being output as floats (i.e. they have a following decimal point!), when I dd() the first and only row without using a Value Binder I get the following:</p>
  
  <pre><code>CellCollection {#862 ▼
    #title: null
    #items: array:8 [▼
      "name" =&gt; "John Smith"
      "refno" =&gt; "s123"
      "nid" =&gt; 1234567890.0
      "birth_date" =&gt; Carbon {#861 ▼
        +"date": "1971-01-05 00:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
      "is_active" =&gt; 1.0
      "course_title" =&gt; "Computer Science"
      "institution_id" =&gt; 1.0
      "course_id" =&gt; 1.0
    ]
  }
  </code></pre>
  
  <p>I've tried implementing a ValueBinder as mentioned in the docs: <a href="http://www.maatwebsite.nl/laravel-excel/docs/import#formatting" rel="nofollow">http://www.maatwebsite.nl/laravel-excel/docs/import#formatting</a> but have had no success yet. I only have one column which needs to be read as a date, the rest should be read as text and the following code doesn't work:</p>
  
  <pre><code>namespace App\Excel;
  
  use PHPExcel_Cell;
  use PHPExcel_Cell_DataType;
  use PHPExcel_Cell_IValueBinder;
  use PHPExcel_Cell_DefaultValueBinder;
  
  class StudentValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
  {
      public function bindValue(PHPExcel_Cell $cell, $value = null)
      {
          if ($cell-&gt;getColumn() !== 'D') {
  
              $cell-&gt;setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
  
              return true;
          }
  
          // else return default behavior
          return parent::bindValue($cell, $value);
      }
  }
  </code></pre>
  
  <p>Any advice would be most appreciated! Thank you.</p>