-
- $reader = PHPExcel_IOFactory::createReader('Excel5'); // How to read excel files. This method is to read the version before excel2007. To read the version after 2007, you can also check the ClassesPHPExcelReader folder. Class (for all reading classes, just fill in the one you need)
- $PHPExcel = $reader->load("info.xls"); // File name
- $sheet = $PHPExcel->getSheet(0) ; // Read the first worksheet starting from 0
- $highestRow = $sheet->getHighestRow(); // Get the total number of rows
- $highestColumn = $sheet->getHighestColumn(); // Get the total columns Number
- // Modify according to the size of your own data table
- $arr = array(1=>'A',2=>'B',3=>'C',4=>'D', 5=>'E',6=>'F',7=>'G',8=>'H',9=>'I',10=>'J',11= >'K',12=>'L',13=>'M', 14=>'N',15=>'O',16=>'P',17=> 'Q',18=>'R',19=>'S',20=>'T',21=>'U',22=>'V',23=>'W ',24=>'X',25=>'Y',26=>'Z');
-
- // Read one row at a time, and then loop the values of each column in the row
- for ($ row = 5; $row <= $highestRow; $row++) {
- for ($column = 1; $arr[$column] != 'T'; $column++) {
- $val = $sheet->getCellByColumnAndRow ($column, $row)->getValue();
- $list[$row][] = $val;
- }
- }
- print_r($list);
Copy code
|