<address id="ousso"></address>
<form id="ousso"><track id="ousso"><big id="ousso"></big></track></form>
  1. php語言

    如何使用php獲取excel文件數據

    時間:2025-06-03 05:54:02 php語言 我要投稿
    • 相關推薦

    如何使用php獲取excel文件數據

      文章主要介紹了php獲取excel文件數據的方法。具有很好的參考價值。下面跟著小編一起來看下吧。

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

      ?

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      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文件中的第一個工作表*/

      $currentSheet = $PHPExcel->getSheet(0);

      /**取得最大的列號*/

      $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()將字符轉為十進制數*/

      $date[$currentRow - 1][] = $val;

      }

      }

      return $date;

    【如何使用php獲取excel文件數據】相關文章:

    如何在PHP導出excel格式數據10-18

    如何實現PHP獲取表單數據與HTML嵌入PHP腳本09-23

    PHP實現獲取FLV文件的時間07-27

    Access 2007中的數據如何導入Excel文件08-11

    PHP如何獲取表單07-27

    PHP如何使用curl實現數據抓取09-27

    如何使用php語言實現文件名稱以及擴展名的獲取08-07

    PHP獲取文件名稱的方法07-05

    如何打開php文件 php文件怎么打開09-06

    <address id="ousso"></address>
    <form id="ousso"><track id="ousso"><big id="ousso"></big></track></form>
    1. 日日做夜狠狠爱欧美黑人