sumuy 2011-08-05 10:55:00 15759次浏览 7条评论 5 0 0

用phpexcel,从数据库中导出excel表

  • 评论于 2012-03-12 08:24 举报

    怎么什么也看不到

  • 评论于 2012-05-29 17:40 举报

    demo呢。。。源码呢。。。

  • 评论于 2012-07-03 17:03 举报

    求phpexcel导入导出使用详细使用方法

  • 评论于 2013-05-21 11:27 举报

    1、下载PHPExcel解压到extensions,修改PHPExcel/PHPExcel_Autoloader解决自动载入问题

    public static function Register() {
        /*if (function_exists('__autoload')) {
            //Register any existing autoloader function with SPL, so we don't get any clashes
            spl_autoload_register('__autoload');
        }
        //Register ourselves with SPL
        return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));*/
        $functions = spl_autoload_functions();
        foreach ($functions as $function)
            spl_autoload_unregister($function);
        $functions = array_merge(array(array('PHPExcel_Autoloader', 'Load')), $functions);
        foreach ($functions as $function)
            $x = spl_autoload_register($function);
            return $x;
    }	//	function Register()
    

    2、修改config/main.php

    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
    ),
    

    3、创建components/Excel.php

    class Excel
    {
        private $phpExcel;
    
        function __construct(PHPExcel $phpExcel)
        {
            $this->phpExcel = $phpExcel;
        }
    
        /**
         * 根据文件名获取PHPExcel对象
         * @param $file
         * @return PHPExcel
         */
        public function getByFile($file)
        {
            $reader = PHPExcel_IOFactory::createReader('Excel5');
            $excel = $reader->load($file);
            return $excel;
        }
    }
    

    4、使用

    $excel = new Excel(new PHPExcel());
    
    1 条回复
    评论于 2017-05-11 13:28 回复

    我按照你的写法来 写了一下 报错不行了 求源码 Email:1844594430@qq.com

  • 评论于 2013-05-23 09:28 举报

    我也是什么看不到呢?

  • 评论于 2013-10-08 10:30 举报

    不错

  • 评论于 2014-09-04 12:37 举报

    什么都木有.....

您需要登录后才可以评论。登录 | 立即注册