How to Dynamic Exporting to Excel by phpExcel

It is very common to have the list exportable to save live table. Doing this with online web list data is not that hard. We would like to recommend using phpExcel to get this work done. However, this tutorial not only introduce that library but also introduce how to using that library dynamically meaning that create your own library to work with the existing library.

Download PHPExcel library.


    require_once './phpexcel/PHPExcel.php';
        <title>Demo Import Excel File</title>
        <table width="40%" border="1" cellspacing="0">
            $i = 0;
            $file_type	= PHPExcel_IOFactory::identify("upload/client.xlsx");
            $objReader	= PHPExcel_IOFactory::createReader($file_type);
            $objPHPExcel    = $objReader->load("upload/client.xlsx");
            $sheet_data	= $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

            foreach ($sheet_data as $row)
                                if($i == 0)
                                    echo "#";
                                    echo $i++;
            <?php }

Leave a Reply

Your email address will not be published. Required fields are marked *