Я делаю функцию для импорта данных, я использую PHPEXCEL, когда я пытаюсь запустить функцию, возникает следующая ошибка: «Ошибка загрузки файла« lrs1.xlsx »: вызов функции-члена setTime () onboolean "что не так с моим кодом?
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
$flag = true;
$i = 1;
Полный код:
public function import()
{
$this->load->helper('file');
if ($this->input->post('submit')) {
$path = 'file_excel/';
require_once APPPATH.'/third_party/PHPExcel.php';
$config['upload_path'] = $path;
$config['allowed_types'] = 'xlsx|xls';
$config['remove_spaces'] = false;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('file')) {
$error = array('error' => $this->upload->display_errors());
} else {
$data = array('upload_data' => $this->upload->data());
}
if (empty($error)) {
if (!empty($data['upload_data']['file_name'])) {
$import_xls_file = $data['upload_data']['file_name'];
} else {
$import_xls_file = 0;
}
$inputFileName = $path.$import_xls_file;
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
$flag = true;
$i = 1;
//unlink($inputFileName);
foreach ($allDataInSheet as $value) {
if ($flag) {
$flag = false;
continue;
}
$nik = $inserdata[$i]['nik'] = $value['C'];
$nikk = $this->m_data->someNik($nik)->num_rows();
if (empty($nikk)) {
// if ($nik > 0) {
// $this->session->set_flashdata('warning', 'There is the same NIK in the Excel.');
// redirect('index.php/admin/indexKaryawan');
// } else {
$inserdata[$i]['no_devisi'] = $value['B'];
$inserdata[$i]['nik'] = $nik;
$inserdata[$i]['name'] = $value['D'];
$inserdata[$i]['direktorat'] = $value['E'];
$inserdata[$i]['devisi'] = $value['F'];
$inserdata[$i]['department'] = $value['G'];
$inserdata[$i]['sub_department'] = $value['H'];
$inserdata[$i]['fungsional_title'] = $value['I'];
$inserdata[$i]['jenis_kelamin'] = $value['J'];
$inserdata[$i]['tempat_lahir'] = $value['K'];
$tahun_lahir = substr($value['L'], 6, 4);
$bulan_lahir = substr($value['L'], 0, 2);
$tanggal_lahir = substr($value['L'], 3, 2);
$gabung_lahir = $tahun_lahir.'-'.$bulan_lahir.'-'.$tanggal_lahir;
$inserdata[$i]['tanggal_lahir'] = $gabung_lahir;
$inserdata[$i]['usia'] = $value['M'];
$inserdata[$i]['etnik'] = $value['N'];
$inserdata[$i]['agama'] = $value['O'];
$inserdata[$i]['pendidikan'] = $value['P'];
$inserdata[$i]['tahun_lulus'] = $value['Q'];
$inserdata[$i]['nama_sekolah'] = $value['R'];
$inserdata[$i]['akreditasi_sekolah'] = $value['S'];
$inserdata[$i]['fakultas'] = $value['T'];
$inserdata[$i]['jurusan'] = $value['U'];
$inserdata[$i]['sub_jurusan'] = $value['V'];
$inserdata[$i]['akreditasi_prodi'] = $value['W'];
$inserdata[$i]['ipk'] = $value['X'];
$inserdata[$i]['teknik'] = $value['Y'];
$inserdata[$i]['fungsional_level'] = $value['Z'];
$inserdata[$i]['d_fungsional'] = $value['AA'];
$inserdata[$i]['m_fungsional'] = $value['AB'];
$inserdata[$i]['y_fungsional'] = $value['AC'];
$inserdata[$i]['grade_len'] = $value['AD'];
$inserdata[$i]['d_grade'] = $value['AE'];
$inserdata[$i]['m_grade'] = $value['AF'];
$inserdata[$i]['y_grade'] = $value['AG'];
$inserdata[$i]['gol'] = $value['AH'];
$inserdata[$i]['gol_pd'] = $value['AI'];
$inserdata[$i]['grade_lama'] = $value['AJ'];
$inserdata[$i]['tmt_startwork'] = $value['AK'];
$inserdata[$i]['tmt_kelrs'] = $value['AL'];
$inserdata[$i]['tmt_rekaprima'] = $value['AM'];
$inserdata[$i]['tmt_futurework'] = $value['AN'];
$inserdata[$i]['tmt_futurework_pensiun'] = $value['AO'];
$inserdata[$i]['mpp'] = $value['AP'];
$inserdata[$i]['pensiun'] = $value['AQ'];
$inserdata[$i]['mandiri'] = $value['AR'];
$inserdata[$i]['bri'] = $value['AS'];
$inserdata[$i]['nama_tabungan'] = $value['AT'];
$inserdata[$i]['bni'] = $value['AU'];
$inserdata[$i]['keterangan_status'] = $value['AV'];
$inserdata[$i]['email'] = $value['AW'];
$inserdata[$i]['nik_ktp'] = $value['AX'];
$inserdata[$i]['telepon'] = $value['AY'];
$inserdata[$i]['telepon_keluarga'] = $value['AZ'];
$inserdata[$i]['npwp'] = $value['BA'];
$inserdata[$i]['bpjs_kesehatan'] = $value['BB'];
$inserdata[$i]['bpjs_ketenagakerjaan'] = $value['BC'];
$inserdata[$i]['tanggal_dokumen'] = $value['BD'];
$inserdata[$i]['nomor_dokumen'] = $value['BE'];
$inserdata[$i]['tmt_dokumen_column1'] = $value['BF'];
$inserdata[$i]['tmt_dokumen_column2'] = $value['BG'];
$inserdata[$i]['keterangan'] = $value['BH'];
$inserdata[$i]['tanggal_dokumen1'] = $value['BI'];
$inserdata[$i]['nomor_dokumen1'] = $value['BJ'];
$inserdata[$i]['tmt_dokumen1_column1'] = $value['BK'];
$inserdata[$i]['tmt_dokumen1_column2'] = $value['BL'];
$inserdata[$i]['keterangan1'] = $value['BM'];
$inserdata[$i]['tanggal_dokumen2'] = $value['BN'];
$inserdata[$i]['nomor_dokumen2'] = $value['BO'];
$inserdata[$i]['tmt_dokumen2_column1'] = $value['BP'];
$inserdata[$i]['tmt_dokume2_column2'] = $value['BQ'];
$inserdata[$i]['keterangan2'] = $value['BR'];
$inserdata[$i]['alamat1'] = $value['BS'];
$inserdata[$i]['alamat2'] = $value['BT'];
$tahun = substr($value['BU'], 6, 4);
$bulan = substr($value['BU'], 0, 2);
$tanggal = substr($value['BU'], 3, 2);
$gabung = $tahun.'-'.$bulan.'-'.$tanggal;
$inserdata[$i]['tgl_msk'] = $gabung;
$tahun_keluar = substr($value['BV'], 6, 4);
$bulan_keluar = substr($value['BV'], 0, 2);
$tanggal_keluar = substr($value['BV'], 3, 2);
$gabung_keluar = $tahun_keluar.'-'.$bulan_keluar.'-'.$tanggal_keluar;
$inserdata[$i]['tgl_keluar'] = $gabung_keluar;
++$i;
// }
// } else {
// $this->session->set_flashdata('warning', 'There is the same NIK in the Database.');
// redirect('index.php/admin/indexKaryawan');
} else {
$this->session->set_flashdata('warning', 'There is the same NIK in the Database.');
redirect('index.php/admin/indexKaryawan');
}
}
$result = $this->m_data->insert_multiple($inserdata);
if ($result) {
$this->session->set_flashdata('success', 'Import Successfully.');
redirect('index.php/admin/indexKaryawan');
} else {
$this->session->set_flashdata('warning', 'Import Failed.');
redirect('index.php/admin/indexKaryawan');
}
} catch (\Throwable $th) {
die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$th->getMessage());
}
} else {
echo $error['error'];
}
} else {
$this->load->view('karyawan');
}
}
что не так с моим кодом?