-
- require_once('include/common.inc.php');
- require_once(rootpath . 'include/phpexcel/phpexcel/iofactory.php');
-
- $filepath = './file/xls/110713.xls';
-
- $filetype = phpexcel_iofactory::identify($filepath); //文件名自动判断文件类型
- $objreader = phpexcel_iofactory::createreader($filetype);
- $objphpexcel = $objreader->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<=$allrow;$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 <= $allrow; $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 . "nn";
- if(!empty($output)){
- printf("%-5st%-15st%-40st%-40st%-5sn", '序号', '赛事类型', '主队', '客队', '让球值');
- foreach($output as $key => $row){
- $format = "%-5dt%-15st%-40st%-40st%-5sn";
- printf($format, $key, $row['type'], $row['master'], $row['guest'], $row['rq']);
- }
- }
- ?>
复制代码
|
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31