循环读取

  1. $objPHPExcel = PHPExcel_IOFactory::load('C:\Users\yi.qin\Downloads\入驻申请单6条数据.xlsx');
  2. $sheet = $objPHPExcel->getActiveSheet();
  3. $highestRow = $sheet->getHighestRow();
  4. $highestColumn = $sheet->getHighestColumn();
  5. for ($row = 1; $row <= $highestRow; $row++) {
  6. for ($column = 'A'; true; $column++) {
  7. $cellValue = $sheet->getCell($column . $row)->getValue();
  8. // 业务代码
  9. if ($column == $highestColumn) {
  10. break;
  11. }
  12. }
  13. }

循环读取

  1. $objPHPExcel = PHPExcel_IOFactory::load('C:\Users\yi.qin\Desktop\a.xlsx');
  2. $sheetData = $objPHPExcel->getActiveSheet()->toArray();
  3. if (!empty($sheetData)){
  4. foreach($sheetData as $i => $item){
  5. // 业务代码
  6. }
  7. }