How to import excel data to oracle database, using phpexcel, or any other alternative.
How to import excel data to oracle database, using phpexcel, or any other alternative.
I managed to do it though i need to validate some columns and redirect the uploaded path instead of putting it manually.
[code]public function actionCreateFleet($page)
{
$model=new COVERNOTEDETAILS;
if(isset($_POST['COVERNOTEDETAILS']))
{
$covernote=$_POST['COVERNOTEDETAILS']['COVER_NOTE_NO'];
//echo 'Code for import goes here!';
Yii::import('ext.phpexcelreader.JPhpExcelReader');
$data = new JPhpExcelReader('uploads/fleet.xls');//[b][font="Arial Black"][code]//I need here to capture the uploaded file path instead of putting it manually.
[/font][/b]
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
{
// check if item number is empty
if (empty($data->sheets[0]['cells'][$i][1]))
continue;
//Getting all the excel data:++++++++++++++++++++++++++++++
for ($j = 2; $j <= $data->sheets[0]['numCols']; $j++)
{
$content[$j] = $data->sheets[0]['cells'][$i][$j];
//echo "\"".$data->sheets[0]['cells'][$i][$j]."\",";
$regno=$data->sheets[0]['cells'][$i][2];
$chassis=$data->sheets[0]['cells'][$i][3];
$vcode=$data->sheets[0]['cells'][$i][4];
$bcode=$data->sheets[0]['cells'][$i][5];
$cc=$data->sheets[0]['cells'][$i][6];
$yom=$data->sheets[0]['cells'][$i][7];
$capacity=$data->sheets[0]['cells'][$i][8];
$value=$data->sheets[0]['cells'][$i][9];
}
Yii::app()->db->createCommand("
INSERT INTO COVER_NOTE_DETAILS(COVER_NOTE_NO,
REGNO,ENGINE_CHASSIS_NO,
VC_VEHICLE_CODE,VC_BODY_CODE,CC,
YEAR_OF_MANUFACTURE,SEATING_CAPACITY,VALUE_OF_VEHICLE)
VALUES('$covernote','$regno','$chassis',$vcode,
$bcode,'$cc','$yom',
'$capacity',$value) ")->execute();
}
$this->redirect(array('index','page'=>$page));
}
}
//Fleets ends here.*************************************************************************************[/code][/code]