如何修复导入excel文件在PHP [英] how to fix import excel file in php
问题描述
这是错误视图
a href =http://i.stack.imgur.com/We2Eo.png =nofollow> pict错误
这是我的代码:
$ 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 harks xls。Apabila ekstensi sudah xls namun gagal,lengkapi data dalam file xls。);< / script>';
$ this-> load-> view('include / header');
$ this-> load-> view('upload_excel_cust');
$ this-> load-> view('include / footer');
}
else
{
$ data = array('error'=> false);
$ upload_data = $ this-> upload-> data();
$ this-> load-> library('Excel_reader');
$ this-> excel_reader-> setOutputEncoding('230787');
$ file = $ upload_data ['full_path'];
$ this-> excel_reader-> read($ file);
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];
我已经读过问题,因为excel_reader文件不支持php 7,
我可以修复它吗?
谢谢...
<
这个问题解决了,我只需要更改名称函数与name类中的相同(__construct)
谢谢..
验证您的PHPExcel文件夹PHPExcel文件在您的third_party文件夹中,然后在您的应用程序/库文件夹中,您需要创建一个Excel.php与
<?php if(!defined('BASEPATH'))exit('不允许直接脚本访问);
require_once APPPATH。/ thirdparty / PHPExcel.php;
类扩展PHPExcel {
public function __construct(){
parent :: __ construct();
}
}
i have problem with import data excel in php use excel_reader.
this is error view
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>';
$this->load->view('include/header');
$this->load->view('upload_excel_cust');
$this->load->view('include/footer');
}
else
{
$data = array('error' => false);
$upload_data = $this->upload->data();
$this->load->library('Excel_reader');
$this->excel_reader->setOutputEncoding('230787');
$file = $upload_data['full_path'];
$this->excel_reader->read($file);
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?
thankyou...
[solved]
this problem solved, i just need change name function same with name class in to (__construct)
thankyou..
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() {
parent::__construct();
}
}
这篇关于如何修复导入excel文件在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!