PHPExcel读取CSV读取值不正确,值具有特殊字符

时间:2017-06-30 06:16:28

标签: php csv phpexcel

我很难正确地从CSV中读取值,正在获取值,但值包含特殊字符e。 g�5�0�0�0�。 我必须对值进行一些计算。将它转换为float / int并没有起作用。

这就是我的做法。

  $inputFileName=$this->fileName;

  /** Include PHPExcel_IOFactory */
  $included=require_once __SITE_PATH.DS.'assets'.DS.'script'.DS.'PHPExcel'.DS.'PHPExcel'.DS.'IOFactory.php';

  if( empty($included) )
  {
     header('HTTP/1.1 400 Bad Request',true,400);
     echo 'xml lib not found';
     return false;
  }

  /** Load $inputFileName to a PHPExcel Object  **/
  //$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);

  /**  Identify the type of $inputFileName  **/
  $inputFileType = PHPExcel_IOFactory::identify($inputFileName);

  /**  Create a new Reader of the type that has been identified  **/
  $objReader = PHPExcel_IOFactory::createReader($inputFileType);

  /**  Advise the Reader that we only want to load cell data  **/
  $objReader->setReadDataOnly(true);

  /**  Advise the Reader of which WorkSheets we want to load  **/
  //$objReader->setLoadSheetsOnly($sheetname);

  /**  Load $inputFileName to a PHPExcel Object  **/
  $this->fileHandler = $objReader->load($inputFileName);

  /*get the worksheet*/
  $objWorksheet = $this->fileHandler->getSheet(0);

  $this->eXjobs=$objWorksheet->toArray(null,true,true,true);

现在当我循环$ this-> eXjobs& var_dump()我可以看到特殊字符的值。

任何帮助都会非常感激。

0 个答案:

没有答案