当前位置: 首页 > 工具软件 > PHPExcel > 使用案例 >

phpExcel 数据读取

酆英达
2023-12-01
<?php
include_once 'E:\project\fapiao\server\php\vendor\phpoffice\phpexcel\Classes\PHPExcel\IOFactory.php';
include_once 'E:\project\fapiao\server\php\vendor\phpoffice\phpexcel\Classes\PHPExcel\Cell.php';

$a = PHPExcel_IOFactory::load('C:\Users\Administrator\Desktop\Gardenia_07051602.xlsx');
$objWorksheet = $a->getSheet(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString ( $highestColumn );
$excelData = [];
for($row = 1; $row <= $highestRow; $row++) {
    for($col = 0; $col < $highestColumnIndex; $col++) {
        echo $objWorksheet->getCellByColumnAndRow( $col, $row )->getValue() . '--';
    }
    echo "<br>";
}
print_r($excelData);

参考:

https://blog.csdn.net/hwhjava/article/details/48023517

 类似资料: