[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