大家好,我在使用LARAVEL从Excel文档中读取一个不是从原始1冒号1(A1)开始的表时遇到问题,在这个文档中有一个标题和一些空行,如图所示:Excel表图像
这是我用来从文档中加载表的代码,同时,如果我删除了所有标题文本和所有空单元格,它也可以正常工作!
Excel::load(Input::file('file'), function($reader) {
// Getting all results
$results = $reader->get();
foreach ($results as $r =>$v) {
$person = new Person;
$person->name = $v['name'];
$person->age = $v['age'];
$person->save();
}
Yupiiii!!找到了解决此问题的方法,方法是转到配置文件:''lavel Project''config''excel.php并更改以下行:
/*
|--------------------------------------------------------------------------
| First Row with data or heading of data
|--------------------------------------------------------------------------
|
| If the heading row is not the first row, or the data doesn't start
| on the first row, here you can change the start row.
|
*/
'startRow' => 1,
并将数字1更改为表格开始的任何一行^^!