在PHP中将多索引Excel文件转换为数组

时间:2018-06-18 12:00:48

标签: php laravel maatwebsite-excel

我已经使用maatwebsite / excel 2.1来读取excel文件但我在阅读多个标题excel文件时遇到了问题(EX:如第一张图所示)。我无法读取所有数据,因为它跳过除第二个标题之外的所有行(如第二个图中突出显示的那样)。

First Image with excel data

Second Image with only fetched data highlighted

数据被提取为:

[
    {"name":"First","0":"F","address":"Country","result":"A"}, 
    {"name":"foo","0":456,"address":"nep","result":324}, 
    {"name":"bar","0":456,"address":"aus","result":324}, 
    {"name":"baz","0":222,"address":"uk","result":21}
    ]

跳过所有其他数据行。因此,我希望在获取所有数据方面寻求帮助,如果可能,还要以有组织的方式提供帮助EX:

["name":{
            "first":"foo",
            "middle":" ",
            "last":"asd"
           },
  "address":{
             "country":"nep",
               ...
               ],
 ...
]

或AS

[{
   "name.first":"foo",
   "name.middle":" ",
   "name.last":"asd",
   "address.country":"nep",
    ......}]

如果使用可用库不可能,那么任何人都可以告诉我如何在PHP(核心级别)中读取excel单个单元格数据。

0 个答案:

没有答案