-
-
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 //判断每一行的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']);
- }
- }
- ?>
复制代码
|
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系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