<?php require_once '/PHPExcel/IOFactory.php';
       //Extra functions
        function get_cell($cell, $objPHPExcel){
            //Cell selection
            $objCell = ($objPHPExcel->getActiveSheet()->getCell($cell));
            //taking cell value
            return $objCell->getvalue();
        }
        function pp(&$var){
            $var = chr(ord($var)+1);
            return true;
        }
    //==========Displaying Code
        $name     = $_FILES['file']['name'];
        $tname    = $_FILES['file']['tmp_name'];
        $type     = $_FILES['file']['type'];

        if($type == 'application/vnd.ms-excel')
        { // excel 97 extension
            $ext = 'xls';
        }
        else if($type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        { // excel 2007 and 2010 extensions
            $ext = 'xlsx';
        }else
        { // invalid extension
            echo -1;
            exit();
        }
        $xlsx = 'test';
        $xls  = 'test';

        //read creator
        $objReader = PHPExcel_IOFactory::createReader($$ext);
        //loading
        $objPHPExcel = $objReader->load($tname);

        $dim = $objPHPExcel->getActiveSheet()->calculateWorksheetDimension();
        // put $start and $end array
        list($start, $end) = explode(':', $dim);

        if(!preg_match('#([A-Z]+)([0-9]+)#', $start, $rslt)){
            return false;
        }
        list($start, $start_h, $start_v) = $rslt;
        if(!preg_match('#([A-Z]+)([0-9]+)#', $end, $rslt)){
            return false;
        }
        list($end, $end_h, $end_v) = $rslt;

        //starting to read excel doc
        $table = "<table class='tabla'>";
        for($v=$start_v; $v<=$end_v; $v++){     
            // calculate progress bar
            $percent = intval($v/$end_v * 100)."%";
            // progress bar update
            echo '<script language="javascript">
            document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\">&nbsp;'.$percent.'</div>";
            document.getElementById("information").innerHTML="'.$v.' files processades.";</script>'; 

            // buffer flush
            echo str_repeat(' ',1024*64);
            // send exit to navigator
            flush();
            sleep(0.25);

            //horizontal reading
            //horizontal reading
 $tempRow= "<tr>";
 $contentFound=false;

 for($h=$start_h; ord($h)<=ord($end_h); pp($h)){
     $cellValue = get_cell($h.$v, $objPHPExcel);
     $tempRow.= "<td>";
     if($cellValue !== null){
         if($cellValue=="I1/027") $contentFound=true;
         $tempRow.= $cellValue;
     }
     $tempRow.= "</td>";
  }
  $tempRow.= "</tr>";

if($contentFound) $table.=$tempRow;

        echo $table;
    ?>