THINKPHP3.2.3整合PHPexcel实现数据的导入导出。可以上传excel文件后批量导入到数据库,兼容.xls和.xlsx格式;数据库里的数据可以按照搜索条件和分页导出为excel文件。
最近接了一个小活,客户要求实现既可以手工录入数据又可以excel文件上传后批量导入到数据库,要求兼容.xls和.xlsx格式;数据库里的数据可以按照搜索条件和分页导出为excel文件。比较麻烦的是excel里的一个机型字段是一对多的,即一个产品对应多个机型,是按照逗号分隔的,导入时要先将机型分隔成数组,然后再判断该机型是否存在,不存在就插入到机型表里,存在则获取到该机型对应的id,然后将id用逗号拼接成字符串存入数据库中。特将代码公开,以方便大家学习。
源码里包含PHPExcel组件,一个控制器文件和一个视图文件,PHPExcel和PHPExcel.class.php放入thinkphp的Library/Org/Util/目录下。
目录结构如右图
如有问题或索要完整代码请加QQ群:421537504 并注明来意。
下载地址http://www.gouguoyin.cn/php/4.html
导出excel页面
导入excel数据页面
导入的数据列表页面
需要导入的EXCEL数据截
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
