php读取excel内容并写入mysql中
2015-05-14 14:49
441 查看
实现功能:上传EXCEL文件,并按照格式导入到数据库中
在网上查找到phpecel 但是phpexcel实在是太大,自身能力有限不能很好的精简,最终找到了phpexcelreader这个类;非常小又能实现我需要的功能
第一步、下载phpexcelReader类(后面给出)
第二步、创建add.php写入如下代码:
$data->dump(true,true); 将excel里面的内容以html形式输出;
第三步、编写html上传文件
写好的例子:http://yun.baidu.com/share/link?shareid=3068641847&uk=2903375990
在网上查找到phpecel 但是phpexcel实在是太大,自身能力有限不能很好的精简,最终找到了phpexcelreader这个类;非常小又能实现我需要的功能
第一步、下载phpexcelReader类(后面给出)
第二步、创建add.php写入如下代码:
$str=$_FILES['excelname']['tmp_name']; $data = new Spreadsheet_Excel_Reader($str); $data_arr = $data->sheets; $all_data = $data_arr[0]['cells']; foreach($all_data as $ak=>$av){ 组织sql语句 }$data->sheets将excel里面的内容以数据形式输出;
$data->dump(true,true); 将excel里面的内容以html形式输出;
第三步、编写html上传文件
<form action='./add' method="post" enctype="multipart/form-data"> <table cellpadding='5px' align='center' width='100%'> <tr> <td><span style='color:red;'>*</span> 请选择文件:</td> <td><input type='file' name='excelname'></td> </tr> <tr> <td colspan='2'><input type='submit' name='submit' value='导入数据'></td> </tr> </table> </form>按照上述流程excel内容就可以正确导入到mysql中
写好的例子:http://yun.baidu.com/share/link?shareid=3068641847&uk=2903375990
相关文章推荐
- PHP读取Excel文件的内容并写入Mysql数据库
- php 读取excel中的内容到mysql 数据库
- php 读取excel中的内容到mysql 数据库
- php从爬虫爬取的txt文件按行读取并写入保存到excel,csv中
- PHP 数据库mysql链接,以及读取数据内容方式详解
- php 结合缓冲区读取excel数据并批量导入mysql
- php从memcache读取数据再批量写入mysql的方法
- PHP读取Excel文件内容
- java 通过poi 读取Excel 写入sqlser mysql
- php读取xml文件内容,并循环写入mysql数据库
- php 导出mysql内容成excel
- php从memcache读取数据再批量写入mysql的方法
- php读取excel内容
- PHP 从数据库Mysql中读取数据生成excel(解决乱码问题,解决中文变问号问题)
- PHP读取EXCEL时写入数据乱码解决办法
- PHP读取Excel文件内容
- PHP+MySQL连续插入数据报错:Commands out of sync; you can't run this command now & 读取Excel数据并批量插入到数据中
- php excel reader读取excel内容存入数据库实现代码
- phpexcel的读取和写入
- php-excel-reader读取excel内容存入数据库