导出数据库数据到excel文件
2013-03-25 19:18
281 查看
php实例:导出数据到excel文件
<?php //开启输出缓存 ob_start(); //连接数据库,查询数据 $conn=mysql_connect('127.0.0.1','root','8888'); mysql_select_db('test',$conn); $query=mysql_query("select * from category") ; ?> <table width="300" border="0"> <tr> <th align="center">ID</th> <th align="center">pID</th> <th align="center">name</th> </tr> <?php while($myrow = mysql_fetch_array($query)){ ?> <tr> <td align="center"><?php echo $myrow["categoryId"]; ?></td> <td align="center"><?php echo $myrow["parentId"]; ?></td> <td align="center"><?php echo $myrow["categoryName"]; ?></td> </tr> <?php } ?> </table> <?php //获取缓存区数据 $data = ob_get_contents(); ob_end_clean(); //保存到excel文件 $fp=fopen('data.xls',"wb"); fwrite($fp,$data); fclose($fp);
echo 'ok'; ?>
相关文章推荐
- poi将数据库数据导出excel文件
- mysql 导出数据到excel文件或将数据导入到数据库
- poi将数据库数据导出excel文件
- 将数据库中的数据导出为Excel文件
- Java Struts2 实现数据库数据导出Excel文件
- 利用Perl把数据库数据导出到Excel文件
- java将数据库数据导出为Excel文件
- java简单的从数据库查询数据使用POI导出excel文件
- JXL把数据库数据导出为EXCEL文件
- 利用ODBC把数据库数据导出为Excel文件
- 数据库中的数据导入导出汇总一(bulk insert命令,bcp命令)
- C#导出数据到Excel文件
- Oracle数据库:impdp导入数据库及expdp导出数据过程详解
- 运用exp 导出oracle数据与 运用imp 将dmp格式数据导入数据库
- 从数据库导出数据到word、excel、.txt(一)
- PHPEXCEL结合MYSQL+PHP实现数据库数据导出EXCEL实例
- Java实现从数据库导出大量数据记录并保存到文件的方法(转)
- MYSQL5.1 WINDOWS环境下导出查询数据到EXCEL文件
- oracle 重建索引以及导出所有的索引脚本(可以解决还原数据库文件时先还原数据,在重新用脚本创建索引)
- 利用数据泵导出远程数据到本地数据库!!!