PHPExcel - How can i read the Excel sheet row by row

前端 未结 4 1688
长发绾君心
长发绾君心 2020-12-11 16:41

How can i read Excel worksheet row by row using PHPExcel? I have a sheet contains more than 100000 rows, but i want to read only 500 rows.

$sheetData = $objP         


        
4条回答
  •  独厮守ぢ
    2020-12-11 17:26

    require_once "/PATH TO PHP EXCEL FOLDER/PHPExcel.php"; 
    $inputFileName = $_FILES['FILENAME'];
    $objTpl = PHPExcel_IOFactory::load('./PATH TO UPLOAD FOLDER/' . $inputFileName);
    $sheetData = $objTpl->getActiveSheet()->toArray(null, true, true, true);
    array_shift($sheetData);
    $i=0;
    $test_array = array();
    foreach($sheetData as $key=>$val){
        if($i < 500)
            $test_array[$i] = $val;
        $i++;   
    }
    

提交回复
热议问题