Postingan lainnya
Data berubah saat import file excel ke database
Data yang ada di database berubah saat berhasil import data dari excel ke database. Ini gimana ya gan solusinya..? Untuk kolomnya yg Jan19 dll saya buat jenis integer *Data pada saat di excel* *Data pada saat berhasil import ke database*
untuk controllernya saya buat seperti ini
public function import(){
$user = $this->ion_auth->user()->row();
// Load plugin PHPExcel nya
include APPPATH.'third_party/PHPExcel/PHPExcel.php';
$excelreader = new PHPExcel_Reader_Excel2007();
$loadexcel = $excelreader->load('excel/'.$this->filename.'.xlsx');
$sheet = $loadexcel->getActiveSheet()->toArray(null, true, true ,true);
$data = array();
$numrow = 4;
foreach($sheet as $row){
if($numrow > 4){
array_push($data, array(
'NO' => $row['A'],
'APIID' => $row['B'],
'Jan19' => str_replace(",", "", $row['C']),
'Feb19' => str_replace(",", "", $row['D']),
'Mar19' => str_replace(",", "", $row['E']),
'Apr19' => str_replace(",", "", $row['F']),
'May19' => str_replace(",", "", $row['G']),
'Jun19' => str_replace(",", "", $row['H']),
'Jul19' => str_replace(",", "", $row['I']),
'Aug19' => str_replace(",", "", $row['J']),
'Sep19' => str_replace(",", "", $row['K']),
'Oct19' => str_replace(",", "", $row['L']),
));
}
$numrow++; // Tambah 1 setiap kali looping
}
$this->m_excel->insert_multiple($data);
redirect("excel_import");
}
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban