PHP 之读取Excel数据

一、示例

include './plugin/PHPExcel/PHPExcel.php';
include './plugin/PHPExcel/PHPExcel/IOFactory.php';
include './plugin/PHPExcel/PHPExcel/Reader/Excel5.php';
extract($_REQUEST);

$inputFileName = "./product.xlsx";
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$sheet = $objPHPExcel->getSheet(0); // 读取第一個工作表
$highestColumm = $sheet->getHighestColumn(); // 取得总列数
$highestRow = $sheet->getHighestRow(); // 取得总行数

for ($i = 1; $i <= $highestRow; $i++) {
    //获取ID
    $id = (string)$objPHPExcel->setActiveSheetIndex()->getCell("A" . $i);
    //获取标题
    $title = (string)$objPHPExcel->setActiveSheetIndex()->getCell("B" . $i);
}

echo "导入数据库完成";

 

posted @ 2021-05-07 09:07  样子2018  阅读(704)  评论(0编辑  收藏  举报