For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Tuesday, November 11, 2014

Read excel file in PHP

Problem:

How to read Excel 2003 or 2007 or 2010 format microsoft excel file in PHP

Solution:

Use  PHPExcel library to read Excel 2003 or 2007 or 2010 format microsoft excel file in PHP.
Download it from it's website

Example:

Below the code that will read excel file.
<?php
require_once './PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('excel2007');//excel2007 or Excel5
$objPHPExcel = $objReader->load("Test.xlsx");

$worksheet=$objPHPExcel->getActiveSheet();
$lastRow = $worksheet->getHighestRow();
$lastCol = $worksheet->getHighestColumn();

for ($row = 2; $row <= $lastRow; $row++){
   echo $worksheet->getCell("A".$row)->getValue()."======";
   echo $worksheet->getCell("B".$row)->getValue()."<br/>"; 
 /// so on.......
}
?>
Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip