无效的单元格坐标错误phpExcel - ?

问题描述 投票:0回答:1

我致力于检索excel数据,但我收到此错误消息:

致命错误:未捕获PHPExcel_Exception:C:\ xampp \ htdocs \ excelUpLoad \ PHPExcel \ Classes \ PHPExcel \ Cell.php中的单元坐标B无效:594堆栈跟踪:#0 C:\ xampp \ htdocs \ excelUpLoad \ PHPExcel \ Classes \ PHPExcel \ Worksheet.php(1218):PHPExcel_Cell :: coordinateFromString('B')#1 C:\ xampp \ htdocs \ excelUpLoad \ PHPExcel \ Classes \ PHPExcel \ Worksheet.php(1178):PHPExcel_Worksheet-> createNewCell('B') #2 C:\ xampp \ htdocs \ excelUpLoad \ main.php(43):PHPExcel_Worksheet-> getCell('B',2)#3 {main}抛出C:\ xampp \ htdocs \ excelUpLoad \ PHPExcel \ Classes \ PHPExcel第594行的\ Cell.php

这是我的代码:

  try
    {
        // 업로드 된 엑셀 형식에 맞는 Reader객체를 만든다.
        $objReader = PHPExcel_IOFactory::createReaderForFile($filename);
        // 읽기전용으로 설정
        $objReader->setReadDataOnly(true);
        // 엑셀파일을 읽는다.
        $objExcel = $objReader->load($filename);
        // 첫번째 시트를 선택
        $objExcel->setActiveSheetIndex(0);
        $objWorksheet = $objExcel->getActiveSheet();
}catch(exception $e)
{
  echo "엑셀파일을 읽는 도중 오류가 발생하였습니다.";
}

echo "<table>";

// print_r ($objWorksheet); //엑셀 파일 읽어 왔는지 확인

$maxRow = $objWorksheet->getHighestRow();

for($i=2; $i<=$maxRow; $i++)
{
  //두번째 행부터 읽어 온다 왜냐하면 첫번째 행은 subject이니깐~~
  echo "<tr>";
  $area = $objWorksheet->getCell('B', $i)->getValue(); //1번째 열
  $area2 = $objWorksheet->getCell('C', $i)->getValue(); //2번째 열
  $mediaName = $objWorksheet->getCell('D', $i)->getValue(); //3번째 열
  $discount = $objWorksheet->getCell('E', $i)->getValue(); //4번째 열
  $locationName = $objWorksheet->getCell('F', $i)->getValue(); //5번째 열
  $displayContent = $objWorksheet->getCell('G', $i)->getValue(); //6번째 열
  $manager = $objWorksheet->getCell('H', $i)->getValue(); //7번째 열
  $FieldContent = $objWorksheet->getCell('I', $i)->getValue(); //8번째 열
  $changeContent = $objWorksheet->getCell('J', $i)->getValue(); //9번째 열
  $blank = $objWorksheet->getCell('K', $i)->getValue(); //10번째 열
  $permissionDate = $objWorksheet->getCell('L', $i)->getValue(); //11번째 열
  $permissionCode = $objWorksheet->getCell('M', $i)->getValue(); //12번째 열
  $code = $objWorksheet->getCell('N', $i)->getValue(); //13번째 열
  $editor = $objWorksheet->getCell('O', $i)->getValue(); //14번째 열
  $lat = $objWorksheet->getCell('P', $i)->getValue(); //15번째 열
  $lng = $objWorksheet->getCell('Q', $i)->getValue(); //16번째 열
  echo"<td>".$area."</td>";
  echo $area;
  echo"<td>".$area2."</td>";
  echo"<td>".$mediaName."</td>";
  echo"<td>".$discount."</td>";
  echo"<td>".$locationName."</td>";
  echo"<td>".$displayContent."</td>";
  echo"<td>".$manager."</td>";
  echo"<td>".$FieldContent."</td>";
  echo"<td>".$changeContent."</td>";
  echo"<td>".$blank."</td>";
  echo"<td>".$permissionDate."</td>";
  echo"<td>".$permissionCode."</td>";
  echo"<td>".$code."</td>";
  echo"<td>".$editor."</td>";
  echo"<td>".$lat."</td>";
  echo"<td>".$lng."</td>";
  echo "</tr>";
}
echo "</table>";

?>

php phpexcel
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.