load($filepath); $currentsheet = $objphpexcel->getsheet(0); //第一个工作簿 $allrow = $currentsheet->gethighestrow(); //行数 $output = array(); $pretype = ''; #// bbs.it-home.org $qh = $currentsheet->getcell('a4')->getvalue(); //按照文件格式从第7行开始循环读取数据 for($currentrow = 7;$currentrow //判断每一行的b列是否为有效的序号,如果为空或者小于之前的序号则结束 $xh = (int)$currentsheet->getcell('b'.$currentrow)->getvalue(); if(empty($xh))break; $tmptype = (string)$currentsheet->getcell('c'.$currentrow)->getvalue(); //赛事类型 if(!empty($tmptype))$pretype = $tmptype; $output[$xh]['type'] = $pretype; $output[$xh]['master'] = $currentsheet->getcell('f'.$currentrow)->getvalue(); //主队 $output[$xh]['guest'] = $currentsheet->getcell('h'.$currentrow)->getvalue(); //客队 } //从当前行开始往下循环,取出第一个不为空的行 for( ; ; $currentrow++){ $xh = (int)$currentsheet->getcell('b'.$currentrow)->getvalue(); if(!empty($xh))break; } for( ; $currentrow $xh = (int)$currentsheet->getcell('b'.$currentrow)->getvalue(); if(empty($xh))break; $output[$xh]['rq'] = $currentsheet->getcell('i'.$currentrow)->getvalue(); } header(content-type:text/html; charset=utf-8); echo '期号:' . $qh . \n\n; if(!empty($output)){ printf(%-5s\t%-15s\t%-40s\t%-40s\t%-5s\n, '序号', '赛事类型', '主队', '客队', '让球值'); foreach($output as $key => $row){ $format = %-5d\t%-15s\t%-40s\t%-40s\t%-5s\n; printf($format, $key, $row['type'], $row['master'], $row['guest'], $row['rq']); }}?>
复制代码