Php Laravel Excel:如何获取单元格的值?
我已加载Php Laravel Excel:如何获取单元格的值?,php,laravel,phpexcel,laravel-excel,Php,Laravel,Phpexcel,Laravel Excel,我已加载.xls文件,其中包含: 如何读取加载的excel文件的单元格值?这方面的文件似乎不清楚 public function get() { $excelFile ... return Excel::load($excelFile, function($doc) { $sheet = $doc->getSheetByName('data'); // sheet with name data, but you can also use sheet ind
.xls
文件,其中包含:
如何读取加载的excel文件的单元格值?这方面的文件似乎不清楚
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);
});
}
你说得对,阅读某些单元格的文档不清楚。
希望这对你有帮助。试试这个
$sheet->getCell('A1')->setCell($sheet->getCell('B1')->getValue);
有关详细信息,请参见本手册
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
...
}
一般来说,如果答案中包含对代码意图的解释,以及为什么在不引入其他代码的情况下解决问题,那么答案会更有帮助。
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
...
}