关于php:phpexcel

7次阅读

共计 558 个字符,预计需要花费 2 分钟才能阅读完成。

require ‘lib/PHPExcel.php’;

set_time_limit(90);
$input_file = “data.xlsx”;
$objPHPExcel = PHPExcel_IOFactory::load($input_file);

$sheet_count = $objPHPExcel->getSheetCount();
for ($s = 0; $s<$sheet_count; $s++)
{

$currentSheet = $objPHPExcel->getSheet($s);// 当前页 
$row_num = $currentSheet->getHighestRow();// 当前页行数 
$col_max = $currentSheet->getHighestColumn(); // 当前页最大列号 

// 循环从第二行开始,第一行往往是表头 
for($i = 2; $i <= $row_num; $i++) 
{$cell_values = array(); 
    for($j = 'A'; $j < $col_max; $j++) 
    { 
        $address = $j . $i; // 单元格坐标 
        $cell_values[] = $currentSheet->getCell($address)->getFormattedValue();} 

    // 看看数据 
    print_r($cell_values); 
} 

}

正文完
 0