0

我正在尝试在 PHPExcel 库的帮助下解析 excel 文件,这是我用于解析表的函数

function readXLS($inputFileName) {
  require_once(LIB_PATH.'PHPExcel.php');

  $inputFileType = PHPExcel_IOFactory::identify($inputFileName);  
  $objReader = PHPExcel_IOFactory::createReader($inputFileType);  
  $objReader->setReadDataOnly(true);

  $objPHPExcel = $objReader->load($inputFileName);
  $objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
  $highestRow = $objWorksheet->getHighestRow();
  $highestColumn = $objWorksheet->getHighestColumn();
  $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);

  $arr_data = array();
  for ($row = 1; $row <= $highestRow; ++$row) {  
    for ($col = 0; $col <= $highestColumnIndex; ++$col) {  
      $value=$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();  
      $arr_data[$row-1][$col]=$value;
    }  
  }
  return $arr_data;
}

当我解析*.xlsx格式时一切正常,但是当我上传解析*.xls格式时出现错误Call to a member function getNamespaces() on a non-object in <b>Z:\home\mysyte\www\trunk\UI\lib\PHPExcel\Reader\Excel2003XML.php

4

0 回答 0