使用maatwebite excel获取特定的行和列

时间:2017-11-03 09:00:22

标签: arrays excel laravel

我是laravel和maatwebsite excel的新手。我需要将excel导入到数据库中 但我只需要导入特定的行和列。

如何在laravel中做到这一点?请帮助我谷歌搜索这种方法好几天没有运气。

非常感谢你的帮助。

这是我的exd读者的dd():

RowCollection {#105908 ▼
  #heading: array:28 [▶]
  #title: "Sheet1"
  #items: array:18 [▶]
}

这是我的详细信息,在第2行中我只需要第6列和第10列

RowCollection {#105908 ▼
  #heading: array:28 [▶]
  #title: "Sheet1"
  #items: array:18 [▼
    0 => CellCollection {#105905 ▼
      #title: null
      #items: array:22 [▶]
    }
    1 => CellCollection {#105323 ▶}
    2 => CellCollection {#105317 ▼
      #title: null
      #items: array:22 [▼
        0 => null
        1 => null
        2 => null
        3 => null
        4 => "Prinsipal"
        5 => null
        6 => "company name"
        7 => null
        8 => "in ctn"
        9 => "Customer:"
        10 => "customer Name"
        11 => null
        12 => null
        13 => null
        14 => null
        15 => null
        16 => null
        17 => null
        18 => null
        19 => null
        20 => null
        21 => null
      ]
    }
    3 => CellCollection {#532 ▶}
    4 => CellCollection {#105286 ▶}
    5 => CellCollection {#105261 ▶}
    6 => CellCollection {#105239 ▶}
    7 => CellCollection {#105210 ▶}
    8 => CellCollection {#105186 ▶}
    9 => CellCollection {#105183 ▶}
    10 => CellCollection {#105160 ▶}
    11 => CellCollection {#105157 ▶}
    12 => CellCollection {#105134 ▶}
    13 => CellCollection {#105131 ▶}
    14 => CellCollection {#105107 ▶}
    15 => CellCollection {#105077 ▶}
    16 => CellCollection {#105082 ▶}
    17 => CellCollection {#105079 ▶}
  ]
}

这是我的详细信息,在第7行我需要第15列到18日才能获得日期

RowCollection {#105908 ▼
  #heading: array:28 [▶]
  #title: "Sheet1"
  #items: array:18 [▼
    0 => CellCollection {#105905 ▼
      #title: null
      #items: array:22 [▶]
    }
    1 => CellCollection {#105323 ▶}
    2 => CellCollection {#105317 ▶}
    3 => CellCollection {#532 ▶}
    4 => CellCollection {#105286 ▶}
    5 => CellCollection {#105261 ▶}
    6 => CellCollection {#105239 ▶}
    7 => CellCollection {#105210 ▼
      #title: null
      #items: array:22 [▼
        0 => null
        1 => null
        2 => null
        3 => null
        4 => null
        5 => "A"
        6 => "B"
        7 => "C=(A+B)"
        8 => "D"
        9 => "E=(C-D)"
        10 => "F"
        11 => "G"
        12 => null
        13 => null
        14 => "H=(F+G)-E"
        15 => Carbon {#105209 ▼
          +"date": "2017-05-05 00:00:00.000000"
          +"timezone_type": 3
          +"timezone": "UTC"
        }
        16 => Carbon {#105156 ▶}
        17 => Carbon {#105182 ▶}
        18 => Carbon {#105187 ▶}
        19 => "Total"
        20 => null
        21 => null
      ]
    }
    8 => CellCollection {#105186 ▶}
    9 => CellCollection {#105183 ▶}
    10 => CellCollection {#105160 ▶}
    11 => CellCollection {#105157 ▶}
    12 => CellCollection {#105134 ▶}
    13 => CellCollection {#105131 ▶}
    14 => CellCollection {#105107 ▶}
    15 => CellCollection {#105077 ▶}
    16 => CellCollection {#105082 ▶}
    17 => CellCollection {#105079 ▶}
  ]
}

最后我需要数据从第8行开始到最后一行 - 1

RowCollection {#105908 ▼
  #heading: array:28 [▶]
  #title: "Sheet1"
  #items: array:18 [▼
    0 => CellCollection {#105905 ▼
      #title: null
      #items: array:22 [▶]
    }
    1 => CellCollection {#105323 ▶}
    2 => CellCollection {#105317 ▶}
    3 => CellCollection {#532 ▶}
    4 => CellCollection {#105286 ▶}
    5 => CellCollection {#105261 ▶}
    6 => CellCollection {#105239 ▶}
    7 => CellCollection {#105210 ▶}
    8 => CellCollection {#105186 ▼
      #title: null
      #items: array:22 [▼
        0 => null
        1 => "Prod X"
        2 => "Product X"
        3 => "Carton"
        4 => null
        5 => null
        6 => 0.0
        7 => 0.0
        8 => null
        9 => 0.0
        10 => null
        11 => null
        12 => 0.0
        13 => null
        14 => 0.0
        15 => 300.0
        16 => 300.0
        17 => 300.0
        18 => 300.0
        19 => 1200.0
        20 => 0.0
        21 => 0.0
      ]
    }
    9 => CellCollection {#105183 ▶}
    10 => CellCollection {#105160 ▶}
    11 => CellCollection {#105157 ▶}
    12 => CellCollection {#105134 ▶}
    13 => CellCollection {#105131 ▶}
    14 => CellCollection {#105107 ▶}
    15 => CellCollection {#105077 ▶}
    16 => CellCollection {#105082 ▶}
    17 => CellCollection {#105079 ▶}
  ]
}

0 个答案:

没有答案