Skip to content

Commit e25d44a

Browse files
Revert "Exclude heading row when limiting imported rows (#4217)" (#4272)
This reverts commit 203d0cd.
1 parent fccd234 commit e25d44a

File tree

2 files changed

+1
-77
lines changed

2 files changed

+1
-77
lines changed

src/Factories/ReaderFactory.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Maatwebsite\Excel\Concerns\MapsCsvSettings;
66
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
7-
use Maatwebsite\Excel\Concerns\WithHeadingRow;
87
use Maatwebsite\Excel\Concerns\WithLimit;
98
use Maatwebsite\Excel\Concerns\WithReadFilter;
109
use Maatwebsite\Excel\Concerns\WithStartRow;
@@ -62,16 +61,8 @@ public static function make($import, TemporaryFile $file, ?string $readerType =
6261
if ($import instanceof WithReadFilter) {
6362
$reader->setReadFilter($import->readFilter());
6463
} elseif ($import instanceof WithLimit) {
65-
$startRow = 1;
66-
67-
if ($import instanceof WithStartRow) {
68-
$startRow = $import->startRow();
69-
} elseif ($import instanceof WithHeadingRow) {
70-
$startRow = 2;
71-
}
72-
7364
$reader->setReadFilter(new LimitFilter(
74-
$startRow,
65+
$import instanceof WithStartRow ? $import->startRow() : 1,
7566
$import->limit()
7667
));
7768
}

tests/Concerns/WithLimitTest.php

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Maatwebsite\Excel\Concerns\Importable;
77
use Maatwebsite\Excel\Concerns\ToArray;
88
use Maatwebsite\Excel\Concerns\ToModel;
9-
use Maatwebsite\Excel\Concerns\WithHeadingRow;
109
use Maatwebsite\Excel\Concerns\WithLimit;
1110
use Maatwebsite\Excel\Concerns\WithStartRow;
1211
use Maatwebsite\Excel\Tests\Data\Stubs\Database\User;
@@ -105,72 +104,6 @@ public function limit(): int
105104
$import->import('import-users.xlsx');
106105
}
107106

108-
public function test_can_import_single_with_heading_row()
109-
{
110-
$import = new class implements ToArray, WithLimit, WithHeadingRow
111-
{
112-
use Importable;
113-
114-
/**
115-
* @param array $array
116-
*/
117-
public function array(array $array)
118-
{
119-
Assert::assertEquals([
120-
[
121-
'Patrick Brouwers',
122-
123-
],
124-
], $array);
125-
}
126-
127-
/**
128-
* @return int
129-
*/
130-
public function limit(): int
131-
{
132-
return 1;
133-
}
134-
};
135-
136-
$import->import('import-users-with-headings.xlsx');
137-
}
138-
139-
public function test_can_import_multiple_with_heading_row()
140-
{
141-
$import = new class implements ToArray, WithLimit, WithHeadingRow
142-
{
143-
use Importable;
144-
145-
/**
146-
* @param array $array
147-
*/
148-
public function array(array $array)
149-
{
150-
Assert::assertEquals([
151-
[
152-
'Patrick Brouwers',
153-
154-
],
155-
[
156-
'Taylor Otwell',
157-
158-
],
159-
], $array);
160-
}
161-
162-
/**
163-
* @return int
164-
*/
165-
public function limit(): int
166-
{
167-
return 2;
168-
}
169-
};
170-
171-
$import->import('import-users-with-headings.xlsx');
172-
}
173-
174107
public function test_can_set_limit_bigger_than_row_size()
175108
{
176109
$import = new class implements ToArray, WithLimit

0 commit comments

Comments
 (0)