Example of phpexcel class library reading excel files
Release: 2016-07-25 08:53:01
Original
1079 people have browsed it
-
- require_once('include/common.inc.php');
- require_once(rootpath . 'include/phpexcel/phpexcel/iofactory.php');
-
- $filepath = './file /xls/110713.xls';
-
- $filetype = phpexcel_iofactory::identify($filepath); //The file name automatically determines the file type
- $objreader = phpexcel_iofactory::createreader($filetype);
- $objphpexcel = $objreader- >load($filepath);
-
- $currentsheet = $objphpexcel->getsheet(0); //First workbook
- $allrow = $currentsheet->gethighestrow(); //Number of rows
- $output = array();
- $pretype = '';
-
- #// bbs.it-home.org
- $qh = $currentsheet->getcell('a4')->getvalue();
- //Follow The file format reads data in a loop starting from line 7
- for($currentrow = 7;$currentrow<=$allrow;$currentrow++){
- //Determine whether column b of each row is a valid serial number, if it is empty or less than The previous sequence number ends
- $xh = (int)$currentsheet->getcell('b'.$currentrow)->getvalue();
- if(empty($xh))break;
-
- $tmptype = ( string)$currentsheet->getcell('c'.$currentrow)->getvalue(); //Event type
- if(!empty($tmptype))$pretype = $tmptype;
- $output[$xh] ['type'] = $pretype;
- $output[$xh]['master'] = $currentsheet->getcell('f'.$currentrow)->getvalue(); //Home team
- $output[ $xh]['guest'] = $currentsheet->getcell('h'.$currentrow)->getvalue(); //Guest team
- }
-
- //Loop down from the current row and take out the first rows that are not empty
- 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 'Issue number:' . $qh . "nn";
- if(!empty($output)){
- printf( "%-5st%-15st%-40st%-40st%-5sn", 'serial number', 'event type', 'home team', 'away team', 'handicap value');
- foreach($output as $key => $row){
- $format = "%-5dt%-15st%-40st%-40st%-5sn";
- printf($format, $key, $row['type'], $row[' master'], $row['guest'], $row['rq']);
- }
- }
- ?>
Copy code
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
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