Reading an Excel File data in PHP

Step1:

Need to add the  PHPExcel Library to the project and need load in php page.

<?php

include "PHPExcel.php";

include "PHPExcel/IOFactory.php";

?>

Step2:

Need to load the excel file to the php file.

$filename = "testing.csv";

Need to identify the file type

$inputFileType = PHPExcel_IOFactory::identify ( $fileName );

$readerObj = PHPExcel_IOFactory::createReader ( $inputFileType );

$excelFile = $readerObj->load ( $fileName );

step3:

Set active sheet to 0(First Sheet)

$excelFile->setActiveSheetIndex ( 0 );

$activeSheet = $excelFile->getActiveSheet();

// Get the highest row in the file( for looping purposes )

$highestRow = $activeSheet->getHighestRow();

for ($i=0; $i<$highestRow $i++){

}

Sign In or Register to comment.