4

I've loaded .xls file with Laravel Excel:

Excel::load('public/files/20160621.xls', function($reader) {
    // read a cell value
});

How do I read values of cells of the loaded excel file? Documentation seems to be unclear on that part.

qwaz
  • 1,285
  • 4
  • 23
  • 47

3 Answers3

8
public function get()
{
    $excelFile ...
    return Excel::load($excelFile, function($doc) {

        $sheet = $doc->getSheetByName('data'); // sheet with name data, but you can also use sheet indexes.

        $sheet->getCell('A1');
        $sheet->getCellByColumnAndRow(0,0);           

    });
}

You're right, the documentation to read some cells is unclear. Hope this will help you.

Demian
  • 390
  • 2
  • 14
0

try this

$sheet->getCell('A1')->setCell($sheet->getCell('B1')->getValue);

more info you can find here

SilentCat
  • 99
  • 1
  • 2
0

for read use this

public function reader($file)
{
    $excel=Excel::load($file, function($reader) {
        $reader->...//Document propities

        $sheet = $doc->getSheet(0); // sheet with index

        $cell=$sheet->getCell('A1')->getValue();       

    })->toArray()//get();
   ...
   $cell=$excel->index//[row][col] Get formatted type(date,currency,calculated) cells
  ...
}
  • Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others. – Tom Aranda Dec 18 '17 at 16:03