Php 如何使用Laravel从包含空行的Excel文档中读取表
大家好,我在从Excel文档中读取表格时遇到问题,该文档不是使用LARAVEL从原始1列1(A1)开始的,在此文档中有一个标题和一些空行,如图所示: 这是我用来从文档中加载表的代码,同时,如果我删除了所有标题文本和所有空单元格,它也可以正常工作Php 如何使用Laravel从包含空行的Excel文档中读取表,php,excel,laravel,laravel-5.2,Php,Excel,Laravel,Laravel 5.2,大家好,我在从Excel文档中读取表格时遇到问题,该文档不是使用LARAVEL从原始1列1(A1)开始的,在此文档中有一个标题和一些空行,如图所示: 这是我用来从文档中加载表的代码,同时,如果我删除了所有标题文本和所有空单元格,它也可以正常工作 Excel::load(Input::file('file'), function($reader) { // Getting all results $results = $reader->get(); foreach ($resul
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();
}
YUPIII!!通过转到配置文件找到此问题的解决方案: \laravel 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更改为表开始的任何行^ ^ 您使用什么扩展名或工具读取excel文件?我使用的是maatwebsite/excel