@@ -94,6 +94,8 @@ public function __construct($reader)
9494 $ this ->reader = $ reader ;
9595 $ this ->excel = $ reader ->excel ;
9696
97+ $ this ->defaultStartRow = $ this ->currentRow = Config::get ('excel::import.startRow ' , 1 );
98+
9799 // Reset
98100 $ this ->reset ();
99101 }
@@ -112,7 +114,7 @@ public function parseFile($columns = array())
112114 $ this ->setSelectedColumns ($ columns );
113115
114116 // If not parsed yet
115- if (!$ this ->isParsed )
117+ if ( !$ this ->isParsed )
116118 {
117119 // Set worksheet count
118120 $ this ->w = 0 ;
@@ -124,13 +126,13 @@ public function parseFile($columns = array())
124126 foreach ($ iterator as $ this ->worksheet )
125127 {
126128 // Check if the sheet might have been selected by it's index
127- if ($ this ->reader ->isSelectedByIndex ($ iterator ->key ()))
129+ if ( $ this ->reader ->isSelectedByIndex ($ iterator ->key ()) )
128130 {
129131 // Parse the worksheet
130132 $ worksheet = $ this ->parseWorksheet ();
131133
132134 // If multiple sheets
133- if ($ this ->parseAsMultiple ())
135+ if ( $ this ->parseAsMultiple () )
134136 {
135137 // Push every sheet
136138 $ workbook ->push ($ worksheet );
@@ -187,7 +189,7 @@ protected function parseWorksheet()
187189 protected function getIndices ()
188190 {
189191 // Fetch the first row
190- $ this ->row = $ this ->worksheet ->getRowIterator (1 )->current ();
192+ $ this ->row = $ this ->worksheet ->getRowIterator ($ this -> defaultStartRow )->current ();
191193
192194 // Set empty labels array
193195 $ this ->indices = array ();
@@ -252,7 +254,7 @@ protected function getSluggedIndex($value, $ascii = false)
252254 $ separator = $ this ->reader ->getSeparator ();
253255
254256 // Convert to ascii when needed
255- if ($ ascii )
257+ if ( $ ascii )
256258 $ value = $ this ->getAsciiIndex ($ value );
257259
258260 // Convert all dashes/underscores into separator
@@ -327,7 +329,7 @@ protected function parseRows()
327329 foreach ($ this ->worksheet ->getRowIterator ($ startRow ) as $ this ->row )
328330 {
329331 // Limit the results when needed
330- if ($ this ->hasReachedLimit ())
332+ if ( $ this ->hasReachedLimit () )
331333 break ;
332334
333335 // Push the parsed cells inside the parsed rows
@@ -351,14 +353,14 @@ protected function getStartRow()
351353 $ startRow = $ this ->defaultStartRow ;
352354
353355 // If the reader has a heading, skip the first row
354- if ($ this ->reader ->hasHeading ())
356+ if ( $ this ->reader ->hasHeading () )
355357 $ startRow ++;
356358
357359 // Get the amount of rows to skip
358360 $ skip = $ this ->reader ->getSkip ();
359361
360362 // If we want to skip rows, add the amount of rows
361- if ($ skip > 0 )
363+ if ( $ skip > 0 )
362364 $ startRow = $ startRow + $ skip ;
363365
364366 // Return the startrow
@@ -400,7 +402,7 @@ protected function parseCells()
400402 $ index = ($ this ->reader ->hasHeading () && isset ($ this ->indices [$ i ])) ? $ this ->indices [$ i ] : $ this ->getIndexFromColumn ();
401403
402404 // Check if we want to select this column
403- if ($ this ->cellNeedsParsing ($ index ))
405+ if ( $ this ->cellNeedsParsing ($ index ) )
404406 {
405407 // Set the value
406408 $ parsedCells [$ index ] = $ this ->parseCell ($ index );
@@ -421,14 +423,14 @@ protected function parseCells()
421423 protected function parseCell ($ index )
422424 {
423425 // If the cell is a date time
424- if ($ this ->cellIsDate ($ index ))
426+ if ( $ this ->cellIsDate ($ index ) )
425427 {
426428 // Parse the date
427429 return $ this ->parseDate ();
428430 }
429431
430432 // Check if we want calculated values or not
431- elseif ($ this ->reader ->needsCalculation ())
433+ elseif ( $ this ->reader ->needsCalculation () )
432434 {
433435 // Get calculated value
434436 return $ this ->getCalculatedValue ();
@@ -473,7 +475,7 @@ protected function encode($value)
473475 list ($ input , $ output ) = array_values (Config::get ('excel::import.encoding ' , array ('UTF-8 ' , 'UTF-8 ' )));
474476
475477 // If they are the same, return the value
476- if ($ input == $ output )
478+ if ( $ input == $ output )
477479 return $ value ;
478480
479481 // Encode
@@ -487,7 +489,7 @@ protected function encode($value)
487489 protected function parseDate ()
488490 {
489491 // If the date needs formatting
490- if ($ this ->reader ->needsDateFormatting ())
492+ if ( $ this ->reader ->needsDateFormatting () )
491493 {
492494 // Parse the date with carbon
493495 return $ this ->parseDateAsCarbon ();
@@ -506,7 +508,7 @@ protected function parseDate()
506508 protected function parseDateAsCarbon ()
507509 {
508510 // If has a date
509- if ($ cellContent = $ this ->cell ->getCalculatedValue ())
511+ if ( $ cellContent = $ this ->cell ->getCalculatedValue () )
510512 {
511513 // Convert excel time to php date object
512514 $ date = PHPExcel_Shared_Date::ExcelToPHPObject ($ this ->cell ->getCalculatedValue ())->format ('Y-m-d H:i:s ' );
@@ -531,9 +533,9 @@ protected function parseDateAsString()
531533 return (string ) PHPExcel_Style_NumberFormat::toFormattedString (
532534 $ this ->cell ->getCalculatedValue (),
533535 $ this ->cell ->getWorksheet ()->getParent ()
534- ->getCellXfByIndex ($ this ->cell ->getXfIndex ())
535- ->getNumberFormat ()
536- ->getFormatCode ()
536+ ->getCellXfByIndex ($ this ->cell ->getXfIndex ())
537+ ->getNumberFormat ()
538+ ->getFormatCode ()
537539 );
538540 }
539541
@@ -545,9 +547,12 @@ protected function parseDateAsString()
545547 protected function cellIsDate ($ index )
546548 {
547549 // if is a date or if is a date column
548- if ($ this ->reader ->getDateColumns ()) {
550+ if ( $ this ->reader ->getDateColumns () )
551+ {
549552 return in_array ($ index , $ this ->reader ->getDateColumns ());
550- } else {
553+ }
554+ else
555+ {
551556 return PHPExcel_Shared_Date::isDateTime ($ this ->cell );
552557 }
553558 }
0 commit comments