0

I use Laravel Excel and I want to load columns separately, like this:

$rows = Excel::selectSheetsByIndex(0)->load($fileName);
$a = $rows->select($column1)->get();
$b = $rows->select($column2)->get();

Where $column1 and column2 are array with the names of columns I want to get.

In my $a i have the column1 but in my $b I have the column1 AND the column2. How to just have the column2 in $b without realoding the Excel file?

EDIT : The solution is to replace:

$a = $rows->select($column1)->get(); 

by :

$a = $rows->get($column1);
Cœur
  • 37,241
  • 25
  • 195
  • 267
K4tn1x
  • 133
  • 3
  • 14

1 Answers1

0

I think you should try this:

$rows = Excel::selectSheetsByIndex(0)->load($fileName);
$a = $rows->get(array('firstname'));
$b = $rows->get(array('lastname'));

Note: firstname and lastname field is your column name

Hope this work for you!

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
  • Thanks it works perfectly, I thought the result would be the same with get but it's not, the documentation is not very clear on that... – K4tn1x Jan 31 '17 at 12:09