CodeIgniter Forums
Import from Excel to MYSQL is not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Import from Excel to MYSQL is not working (/thread-60304.html)



Import from Excel to MYSQL is not working - El Forum - 02-26-2014

[eluser]hrg.vincent[/eluser]
Controller
Code:
//load library phpExcel
$this->load->library('PHPExcel');
  
// File Location
$inputFileName = './attach/flexi.xlsx';
  
//Load $inputFileName to a PHPExcel Object  
$inputFileType = 'Excel2007';
$objReader = new PHPExcel_Reader_Excel2007();
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);

for ($i=1; $i<=77; $i++){
$category = $objWorksheet->getCellByColumnAndRow(0,$i)->getValue();
$description = $objWorksheet->getCellByColumnAndRow(1,$i)->getValue();
$transaction_date = $objWorksheet->getCellByColumnAndRow(2,$i)->getValue();
$amount = $objWorksheet->getCellByColumnAndRow(3,$i)->getValue();
$employee_id = $objWorksheet->getCellByColumnAndRow(4,$i)->getValue();  
  
$data_flexi = array(
  'category'   => $category,
  'description'  => $description,
  'transaction_date'  => $transaction_date,
  'amount'   => $amount,
  'employee_id'  => $employee_id,
  'create_by'   => '2'
);
}

$this->Flex_m->upload_flexi($data_flexi);
$this->load->view('flex/thanks');

Model
Code:
$this->db->insert(FLEXI_TABLE, $data_flexi);
return $this->db->insert_id();

Any wrong from my code in Controller? I can't load the excel and import into MYSQL. Please help


Import from Excel to MYSQL is not working - El Forum - 02-26-2014

[eluser]InsiteFX[/eluser]
Do a var_dump($data); before you call the upload.



Import from Excel to MYSQL is not working - El Forum - 02-27-2014

[eluser]hrg.vincent[/eluser]
problem solved.. but the problem is the file must be in server and not user.. anyone know how to solve for it??