Postingan lainnya
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
Object of class DateTime could not be converted to string
nanya ini cara convert nya bagaimana ? di mysql sudah ku coba tipe data date, datetime, varchar, text tapi masih tetep muncul.. masalahnya di cell "Tanggal beli" excel. harus gimana biar sinkron bisa di upload ?
"Object of class DateTime could not be converted to string"
dadw.png
Controler import/upload Excel
public function uploadexcel()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'xlsx|xls';
$config['file_name'] = 'doc' . time();
$this->load->library('upload', $config);
if ($this->upload->do_upload('importexcel')) {
$file = $this->upload->data();
$reader = ReaderEntityFactory::createXLSXReader();
$reader->open('uploads/' . $file['file_name']);
foreach ($reader->getSheetIterator() as $sheet) {
$numRow = 1;
foreach ($sheet->getRowIterator() as $row) {
if ($numRow > 1) {
$dataasset = array(
'id_category' => $row->getCellAtIndex(1),
'no_asset' => $row->getCellAtIndex(2),
'name' => $row->getCellAtIndex(3),
'description' => $row->getCellAtIndex(4),
'merek' => $row->getCellAtIndex(5),
'kw' => $row->getCellAtIndex(6),
'position' => $row->getCellAtIndex(7),
'toonase' => $row->getCellAtIndex(8),
'x' => $row->getCellAtIndex(9),
'y' => $row->getCellAtIndex(10),
'z' => $row->getCellAtIndex(11),
'type_spek' => $row->getCellAtIndex(12),
'tgl_beli' => $row->getCellAtIndex(13),
'harga_beli' => $row->getCellAtIndex(14),
'persen' => $row->getCellAtIndex(15),
'masa_depresiasi' => $row->getCellAtIndex(16),
'asset_kontrol_ketua' => $row->getCellAtIndex(17),
'asset_kontrol_wakil' => $row->getCellAtIndex(18),
'status' => $row->getCellAtIndex(19),
);
$this->m_assetdata->import_data($dataasset);
}
$numRow++;
}
$reader->close();
unlink('uploads/' . $file['file_name']);
$this->session->set_flashdata('success', 'Import Excel berhasil');
redirect('asset_data');
}
} else {
echo "Error : " . $this->upload->display_errors();
}
}
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban