ebookz

11-19-2012, 02:40 PM

This is my mydata.xls excel sheet image:http://i.imgur.com/LjPcw.png

php code :

<?php

// include class file

include("Excel/reader.php");

// initialize reader object

$excel = new Spreadsheet_Excel_Reader();

// read spreadsheet data...

$excel->read('mydata.xls');

// iterate over Excel sheet cells and save to database table//////////

$x=2;

while($x<=$excel->sheets[0]['numRows']) {

$y=1;

while($y<=$excel->sheets[0]['numCols']) {

//check empty cell...

if(isset($excel->sheets[0]['cells'][$x][$y])){

//save data to an array..

$z=$y-1;

$data[$z]=$excel->sheets[0]['cells'][$x][$y];

}

$y++;

} //end 2 while

//store array values to variables..

$st_id=$data[0];

$marks=$data[1];

$co_type=$data[2];

$status=$data[3];

echo $st_id."</br>";

$x++;

}//end 1 while

?>

out put :http://i.imgur.com/kTMBu.png

problem: how to stop showing last row repeated.....?????????????last row value print many no of times how to stop that?? plzz tell the code error & how to fix this problem???? Actually I'm trying to insert those data to my database table..before do that I tried to print one of this variable & see the result...

php code :

<?php

// include class file

include("Excel/reader.php");

// initialize reader object

$excel = new Spreadsheet_Excel_Reader();

// read spreadsheet data...

$excel->read('mydata.xls');

// iterate over Excel sheet cells and save to database table//////////

$x=2;

while($x<=$excel->sheets[0]['numRows']) {

$y=1;

while($y<=$excel->sheets[0]['numCols']) {

//check empty cell...

if(isset($excel->sheets[0]['cells'][$x][$y])){

//save data to an array..

$z=$y-1;

$data[$z]=$excel->sheets[0]['cells'][$x][$y];

}

$y++;

} //end 2 while

//store array values to variables..

$st_id=$data[0];

$marks=$data[1];

$co_type=$data[2];

$status=$data[3];

echo $st_id."</br>";

$x++;

}//end 1 while

?>

out put :http://i.imgur.com/kTMBu.png

problem: how to stop showing last row repeated.....?????????????last row value print many no of times how to stop that?? plzz tell the code error & how to fix this problem???? Actually I'm trying to insert those data to my database table..before do that I tried to print one of this variable & see the result...