Laravel-excel: How to Ignore or skip specific column?

Created on 2 Sep 2017  ·  3Comments  ·  Source: Maatwebsite/Laravel-Excel

How can Ignore or skip specific columns? For example I have the ff. columns:

firstname, middlename, lastname, age

and I want to load only

firstname, lastname

so basically ignoring middlename and age column.

thanks in advance.

Most helpful comment

I also want to know that.

All 3 comments

I also want to know that.

// Select
$reader->select(array('firstname', 'lastname'))->get();

// Or
$reader->get(array('firstname', 'lastname'));

source: http://www.maatwebsite.nl/laravel-excel/docs/import#select

@rootchips, thanks for the answer. I also saw that from the documentation before. But here are it's disadvantage.

  1. If I have an excel file which has 50 or more columns/headers and I only need to ignore 2 or 3 of it, so the code would be very long.
  2. I'm uploading files with random or custom columns, every file I need to select which column should be ignored. So specifying selected only columns would not help.

If only I could get answer from this issue https://github.com/Maatwebsite/Laravel-Excel/issues/1165, I might be using this library.

Was this page helpful?
0 / 5 - 0 ratings