The following editor will bring you an article on how to use PHP to upload batches to the database using PHPExcel. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let's follow the editor and take a look.
This example only uses the .xls file of execel2003. If you are using other versions, you can save it in the format of "Execel 97-2003 workbook (*.xls)". xls file type is enough!
Function description: Only Excel2003 type xls files can be uploaded, the size does not exceed 5M. The downloadable example template can be uploaded after adding data!
Front-end test.php page
##
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Backend Process.php page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
The effect is:If the file to be uploaded is not selected, it will prompt "No table selected"; if the table file exceeds 5M, it will prompt; if the file type to be uploaded is not xls, it will prompt!
The above is the detailed content of Use PHPExcel to upload data in batches. For more information, please follow other related articles on the PHP Chinese website!