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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive