Laravel Excel:如何获得细胞的价值?

时间:2016-06-28 11:20:04

标签: php laravel phpexcel laravel-excel

我已将.xls文件加载到Laravel Excel

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

如何读取加载的excel文件的单元格值?文档似乎不清楚。

3 个答案:

答案 0 :(得分: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);           

    });
}

你是对的,阅读一些细胞的文档还不清楚。 希望这会对你有所帮助。

答案 1 :(得分:0)

供阅读使用

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
  ...
}

答案 2 :(得分:-1)

试试这个

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

您可以找到here

的更多信息