Yii Framework Forum: Excel Import To Oracle Database Using Phpexcel Reader - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Excel Import To Oracle Database Using Phpexcel Reader Excel data import to Oracle database.

#1 User is offline   mpande 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-September 12
  • Location:DSM,Tanzania

Posted 10 October 2012 - 02:45 AM

How to import excel data to oracle database, using phpexcel, or any other alternative.
0

#2 User is offline   mpande 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-September 12
  • Location:DSM,Tanzania

Posted 10 October 2012 - 11:18 AM

View Postmpande, on 10 October 2012 - 02:45 AM, said:

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]
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users