人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動(dòng)態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      php獲取excel文件數(shù)據(jù)

php獲取excel文件數(shù)據(jù)

標(biāo)簽: 發(fā)布日期:2017-04-21 00:00:00 251

很簡單就可以實(shí)現(xiàn),下面為大家簡單介紹下

1、下載PHPExcel類,是一個(gè)文件夾,還得有一個(gè)文件PHPExcel.php,兩個(gè)在同級目錄

require __DIR__ . './PHPExcel/IOFactory.php';

  $PHPReader = new \PHPExcel_Reader_Excel2007();

  //判斷文件類型
  if (!$PHPReader->canRead($filePath)) {
   $PHPReader = new \PHPExcel_Reader_Excel5();

   if (!$PHPReader->canRead($filePath)) {
    echo 'no Excel';
    return false;
   }
  }

  $PHPExcel = $PHPReader->load($filePath);
  /**讀取excel文件中的第一個(gè)工作表*/

  $currentSheet = $PHPExcel->getSheet(0);
  /**取得最大的列號(hào)*/

  $allColumn = $currentSheet->getHighestColumn();
  /**取得一共有多少行*/

  $allRow = $currentSheet->getHighestRow();

  /**從第1行開始輸出*/
  for ($currentRow = 1; $currentRow <= $allRow; $currentRow++) {

   /**從第A列開始輸出*/
   for ($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn++) {
    $val = $currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65, $currentRow)->getValue();
    /**ord()將字符轉(zhuǎn)為十進(jìn)制數(shù)*/
    $date[$currentRow - 1][] = $val;
   }

  }
  return $date;