我需要读取一个.xls
文件并将其放入一个数组中。我正在使用laravel-excel包来读取 excel 文件。
我有一个这样的 Excel 文件:
我需要有一个这样的数组:
[
'9921234567' => 'First Text',
'9929876544' => 'Second Text',
'9927654321' => 'Third Text',
'9928765432' => 'Fourth Text',
]
到目前为止我所尝试的:
Excel::load('sample.xls', function($reader) {
$reader->dd();
});
问题:
问题是它将第一行读取为列!
0 => RowCollection {#619
#title: "Sheet1"
#items: array:3 [
0 => CellCollection {#623
#title: null
#items: array:2 [
9921234567 => 9929876544.0
"first_text" => "Second Text"
]
}
1 => CellCollection {#624
#title: null
#items: array:2 [
9921234567 => 9927654321.0
"first_text" => "Third Text"
]
}
2 => CellCollection {#625
#title: null
#items: array:2 [
9921234567 => 9928765432.0
"first_text" => "Fourth Text"
]
}
]
}
看,我不想将第一行值算作列名!
任何帮助将不胜感激。