php - Reading excel file in Laravel -


i'm using maatwebsite's library reading , creating excel file. creating easy , somehow intuitive, when comes reading one, can't figure out.

this how excel file looks like: enter image description here

i figured out how loop through rows, confused me $row in example type of string, can't $row->something;

in controller want read this:

 excel::load('storage\\exports\\'. $fname, function($reader) {     $reader->each(function($sheet) {         log::warning("sheet happens");          // loop through rows                     $sheet->each(function($row) {             log::warning($row);         });      }); }); 

this gives me output

[2016-01-28 06:42:05] local.warning: sheet happens   [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning:    [2016-01-28 06:42:05] local.warning: sheet happens   [2016-01-28 06:42:05] local.warning: ocjena   [2016-01-28 06:42:05] local.warning: kolokvijum 1 (%)   [2016-01-28 06:42:05] local.warning: kolokvijum 2   [2016-01-28 06:42:05] local.warning: kolokvijum 2 (%)   [2016-01-28 06:42:05] local.warning: završni ispit (%)   [2016-01-28 06:42:05] local.warning: završni ispit   

it confused me output not in right order.

it confused me row type of string. why?

is possible access specific cells in matrix: $table[$row][$column]; ?

if can't answer question apreciate if have piece of working code since there not docs online.

edit: found out have multiple words @ headers, somehow gets mixed up.

edit: cause there not docs online feel should share solved it.

the solution code:

$rows = excel::load('storage\\exports\\'. $fname)->get(); log::warning($rows); 

prints out:

[{"ime_studenta":"andrej","broj_indeksa":4,"kolokvijum_1":4,"kolokvijum_2":4,"zavrsni_ispit":44,"ukupno":4,"ocjena":4},{"ime_studenta":"as","broj_indeksa":342,"kolokvijum_1":123,"kolokvijum_2":57,"zavrsni_ispit":56,"ukupno":5656,"ocjena":56}]  

maybe useful you

$rows = excel::load('storage\\exports\\'. $fname)->get(); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -