ridho pratama ridho pratama - 2 years ago 251
PHP Question

how to fix import excel file in php

i have problem with import data excel in php use excel_reader.

this is error view

pict error

this is my code :

$config['upload_path'] = './assets/excel/';
$config['allowed_types'] = 'xls';
$config['max_size'] = 1024 * 8;

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
echo'<script>alert("Upload gagal. Perhatikan ekstensi file. Ekstensi harus xls. Apabila ekstensi sudah xls namun gagal, lengkapi data dalam file xls.");</script>';

$data = array('error' => false);
$upload_data = $this->upload->data();


$file = $upload_data['full_path'];
error_reporting(E_ALL ^ E_NOTICE);

// Sheet 1
$data = $this->excel_reader->sheets[0] ;
$dataexcel = Array();
for ($i = 1; $i <= $data['numRows']; $i++) {

if($data['cells'][$i][1] == '') break;
$dataexcel[$i-1]['tgl'] = $data['cells'][$i][2];
$dataexcel[$i-1]['nama_tempat'] = $data['cells'][$i][3];

i've been read the problem cause excel_reader file not support in php 7,
how i can fix it?



this problem solved, i just need change name function same with name class in to (__construct)


Answer Source

Hi to read excel file you can read this post read excel file

Verify that your PHPExcel folderPHPExcel file are in your third_party folder, then in your application/library folder you need to create a Excel.php with

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

require_once APPPATH."/third_party/PHPExcel.php";

class Excel extends PHPExcel {

    public function __construct() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download