php利用ExcelFileParser把excel导入数据库
这是一款实用的php教程利用excelfileparser把excel导入数据库教程,代码如下:
<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>excel数据获取演示</title> <meta name="keywords" content="todo" /> <meta name="description" content="todo"/> </head> <body> <div> <div>excel数据获取演示</div> <div> <form method="post" action="/index/parse" enctype="multipart/form-data"> <input type="file" name="excel" value="" /> <input type="submit" name="submit" value="提交" /> </form> </div> </div> </body> </html>
parese.php文件,代码如下:
<?php /** * copyright (c) 2009, * all rights reserved. * 文件名: * 摘 要: * * @author 星期八 [url=mailto:ixqbar@hotmail.com]ixqbar@hotmail.com[/url] * @version */ public function parse() { /** * $_files数组说明 * array(n) { * ["表单文件框名称"] => array(5) { * ["name"] => 提交文件名称 * ["type"] => 提交文件类型 excel为"application/vnd.ms-excel" * ["tmp_name"] => 临时文件名称 * ["error"] => 错误(0成功1文件太大超过upload_max_filesize2文件太大超过max_file3上传不完整4没有上传文件) * ["size"] => 文件大小(单位:kb) * } * } */ $return=array(0,''); /** * 判断是否提交 * is_uploaded_file(文件名称)用于确定指定的文件是否使用post方法上传,防止非法提交,通常和move_upload_file一起使用保存上传文件到指定的路径 */ if(!isset($_files) || !is_uploaded_file($_files['excel']['tmp_name'])) { $return=array(1,'提交不合法'); } //处理 if(0 == $return[0]) { import('@.util.excelparser'); $excel=new excelparser($_files['excel']['tmp_name']); $return=$excel->main(); } //输出处理 print_r($return); ?>
文章链接:
随便收藏,请保留本文地址!

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Laravel development: How to use LaravelExcel to implement Excel import and export? During development, Excel tables are often used for data processing, such as data import and export. LaravelExcel is a simple and powerful Laravel extension that allows us to easily process Excel files, including reading, writing, and exporting operations of Excel files. In this article we will introduce how to use LaravelExcel

With the development of the Internet, there are increasing needs for data import and export, especially in enterprises. As a very popular office software, Excel is also widely used for data storage and processing. Therefore, how to use ThinkPHP6 to import and export Excel has become a very important issue. This article will introduce the steps for Excel import and export using ThinkPHP6. 1. Excel export ThinkPHP6 provides a very convenient Excel export tool class

Summary of common problems when importing Excel data into Mysql: How to solve the garbled problem encountered when importing data? Importing Excel data into Mysql database is a common task in daily work. However, sometimes during the import process, garbled characters may be encountered, resulting in incorrect data display. This article will summarize common garbled code problems and provide solutions to help readers solve the garbled code problem when importing data. Problem: After importing data, Chinese characters become garbled and appear as a string of garbled characters. Solution: Generally speaking, this is due to the character

How to use the Hyperf framework to import Excel requires specific code examples. Introduction: With the development of informatization, spreadsheets play an important role in our daily work. During the development process, we often encounter situations where we need to import data from Excel into the system. This article will introduce how to use the Hyperf framework for Excel import and provide specific code examples. 1. Install the necessary plug-ins. Before using the Hyperf framework to import Excel, we need to install two plug-ins.

With the increasing popularity of Internet applications and the growing demand for interaction between various types of data and data transfer, file format conversion, import and export have become one of the common needs. In web applications, importing and exporting Excel files are common ways of data exchange in daily work. This article will introduce how to implement Excel import and export functions in the ThinkPHP6 framework. 1. Introduction to ThinkPHP6 framework ThinkPHP6 is a free, open source, fast and simple object-oriented lightweight framework.

Summary of frequently asked questions about importing Excel data into Mysql: How to solve data verification problems encountered during the import process? Importing Excel data into a MySQL database is an operation we often need to perform in data processing work. However, we often encounter some data verification problems during this process, causing the import to fail or the imported data not to meet our expectations. The following will introduce some common problems and solutions to help you avoid these troubles in actual operations. Question 1: When importing Excel data, Mysq

Summary of frequently asked questions about importing Excel data into Mysql: How to solve primary key conflicts encountered during import? Importing data is one of the common tasks in data management work, especially when you need to import a large amount of data from an Excel table to a Mysql database, you may encounter a variety of problems. One of the common problems is primary key conflict. Primary key conflict problems generally occur when importing data. The main reason is that the data in the Excel table conflicts with the primary key of the existing data in the database. This may be because Excel

With the rapid development of the Internet, Excel has become one of the important tools in daily office work for companies and individuals. Therefore, Excel's ability to import and export has become a necessary part of many applications. How to use ThinkPHP6 to implement Excel import and export? Below, this article will introduce it to you in detail. 1. ThinkPHP6 system environment verification To use ThinkPHP6 to implement Excel import and export, you first need to meet the system environment requirements. In ThinkPHP6, you can use c
