AUTOMATION IN FORM USING EXCEL FILE

Hello friends my new task is make script for form automation.in this script which user not need fill data by hand they just click on button and data will automatically fill in database.

sir gave a task for me and all group members .i do this task USE oF PHP AND API

i use the phpexcl api. with help i do this task

now start how it work;

download the api from this link:

http://phpexcel.codeplex.com/releases/view/88098

and use the simple coding for this task

<?php

$objexcel=PHPExcel_IOFactory::load(“example2.xls”);    //library file
foreach($objexcel->getWorksheetIterator() as $worksheet)
{
$worksheetTitle=$worksheet->getTitle();                                                               //for title of file
echo $highestRow=$worksheet->getHighestRow();                                           //count the rows in file
$highestColumn=$worksheet->getHighestColumn();                                         // column of file in character
$highestColumnIndex=PHPExcel_Cell::columnIndexFromString($highestColumn); //convert the character into number
$nrColumns=ord($highestColumn)-64;
for($row=$_SESSION[‘val’];$row<=highestRow;++$row)
{
for($col=0;$col<=$highestColumnIndex;++$col)
{
$cell=$worksheet->getCellByColumnAndRow($col,$row);
$val[$col]=$cell->getvalue();                                                                          //store value in array
$dataType=PHPExcel_Cell_DataType::dataTypeForValue($val);

}
echo ‘</tr>’;
}
echo ‘</table>’;
}}
echo “<form action=’ex.php’ method=’post’>”;
echo “<table>”;
echo “<tr><td>NAME</td><td><input type=’text’ name=’t1′ value='”.$val[0].”‘></td></tr>”;
echo “<tr><td>rollno</td><td><input type=’text’ name=’t2′ value='”.$val[1].”‘></td></tr>”;
echo “<tr><td>class</td><td><input type=’text’ name=’t3′ value='”.$val[2].”‘></td></tr>”;
echo “<tr><td>branch</td><td><input type=’text’ name=’t4′ value='”.$val[3].”‘></td></tr>”;
echo “<tr><td>college</td><td><input type=’text’ name=’t5′ value='”.$val[4].”‘></td></tr>”;
echo “<tr><td>mobile</td><td><input type=’text’ name=’t6′ value='”.$val[5].”‘></td></tr>”;
echo “<tr><td>phone nu</td><td><input type=’text’ name=’t7′ value='”.$val[6].”‘></td></tr>”;
echo “<tr><td>helo</td><td><input type=’text’ name=’t8′ value='”.$val[7].”‘></td></tr>”;
echo “<tr><td>mt</td><td><input type=’text’ name=’t9′ value='”.$val[8].”‘></td></tr>”;
echo “<tr><td>N</td><td><input type=’text’ name=’t10′ value='”.$val[9].”‘></td></tr>”;
echo “<tr><td><input type=’submit’ value=’ok’ name=’submit’><input type=’submit’ value=’RESET’ name=’reset’><input type=’submit’ value=’LOGOUT’ name=’logout’></td></tr></form>”;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s