mercredi 18 janvier 2017

How to get random cell using phpExcel

Hi friends am trying to get the random cell using phpexcel Here is my code..

 <html>
     <head>

      </head>
   <body>
      <?php

       require_once "Classes/PHPEXCEL.php";

          $tmpfname = "test.xlsx";
         $excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
         $excelObj = $excelReader->load($tmpfname);
         $worksheet = $excelObj->getSheet(0);
        $lastRow = $worksheet->getHighestRow();

    echo "<table>";
    for ($row = 1; $row <= $lastRow; $row++) {
         echo "<tr><td>";
         echo $worksheet->getCell('A'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('B'.$row)->getValue();
         echo "</td><tr>";
    }
    echo "</table>";

    ?>

</body>
 </html>

How can I get the random cell from a column instead of particular column

 Key    Value
  Dog   1
  Cat   2
  Horse 3




Aucun commentaire:

Enregistrer un commentaire