Export excel table BackendProce"/> Export excel table BackendProce">
Home > Article > Backend Development > Simple example of batch exporting data to excel
First you need to download the PHPExecel class file. For help documentation, please refer to the PHPExcel Chinese Help Manual|How to use PHPExcel.
The example below is a simple example of batch exporting data to excel that I wrote myself
Front page It is relatively simple, just a hyperlink, jump To the processing page, the hyperlink can also be followed by some parameters (depending on the requirements)!
<a href="./Process1.php">导出excel表格</a>
Backend Process.php page
expExcel(, 'PHPExcel.php' = ->getProperties()->setCreator("zxf") ->setLastModifiedBy("zxf") ->setTitle('数据EXCEL导出') ->setSubject('数据EXCEL导出') ->setDescription('导出数据') ->setKeywords("excel") ->setCategory("result file"); ->setActiveSheetIndex(0->->setCellValue('A1', '业主姓名'->setCellValue('B1', '密码'->setCellValue('C1', '手机号码'->setCellValue('D1', '地址'->getStyle('A1:D1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color:: = 1( ++-> ->setCellValue('A'., ['name'->setCellValue('B'., ['pwd'->setCellValue('C'., ['phone'->setCellValue('D'., ['address'->setActiveSheetIndex(0('Content-Type: application/vnd.ms-excel'); ('Content-Disposition: attachment;filename="'..'.xls"'); ('Cache-Control: max-age=0'('Content-Type: text/html; charset=utf-8'); = PHPExcel_IOFactory::createWriter(, 'Excel5'); ->save('php://output'("Content-type:text/html;charset=utf-8" = @('localhost','root','') or ('连接数据库失败'('test',('set names utf8' = "select * from house" = ( = ( = ([] = = "用户表"expExcel(,)
This is the end of exporting data using PHPExcel. For information on using PHPExcel to import data into the database, please refer to Using PHPExcel to batch upload data to the database
The above is the detailed content of Simple example of batch exporting data to excel. For more information, please follow other related articles on the PHP Chinese website!