Welcome Guest, Not a member yet? Register   Sign In
Import from Excel to MYSQL is not working

//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->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

Do a var_dump($data); before you call the upload.

problem solved.. but the problem is the file must be in server and not user.. anyone know how to solve for it??

Theme © iAndrew 2016 - Forum software by © MyBB