PHPExcel 讀取Excel以xlsx格式的文件(轉)

(1)首先從github上下載PHPExcel,
(2)拷貝到本地服務器運行的文件夾下
(3)載入PHPExcel類和IOFactory類
(4)讀取excel文件
(5)讀取行列對應的數值即可

<?php
require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';
$path = "./data.xlsx";
$fileType = PHPExcel_IOFactory::identify($path);
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($path);
$currentSheet = $objPHPExcel->getSheet(0);

for ($i = 10; $i <= 17; $i++){
    $result = (string) ($currentSheet->getCell('I'.$i)->getValue());
    echo $result . "</br>";
}

參考文章鏈接
————————————————
版權聲明:本文爲CSDN博主「yangshuolll」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/worldmakewayfordream/article/details/78556706

發佈了362 篇原創文章 · 獲贊 89 · 訪問量 184萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章