php export data to execl file format
Release: 2016-07-25 09:08:27
Original
1083 people have browsed it
php将数据导出为execl文件格式
- ?
session_start();
- $sql_excel="";
- if(isset($_SESSION["excel"]))
- {
- $sql_excel=$_SESSION["excel"];
- }
- //unset($_SESSION["excel"]);
- $conn=mysql_connect("localhost","root","");
- mysql_select_db("test");
- mysql_query("set names utf8",$conn);
- $result=mysql_query($sql_excel);
- header("Content-type:application/vnd.ms-excel");
- header("Content-Disposition:attachment;filename=export_data.xls");
- //$result=mysql_query($sql_excel);
- $result=mysql_query($sql_excel);
- while($arr = mysql_fetch_assoc($result)){
- $content[]=$arr;
- }
- // print_r($content);
- $table = '
- $table .= '
- $table .= '
- foreach($content as $key=>$value){
- $table .= "
- $table .= "
- $table .= "
- $table .= "
- $table .= "
- $table .= "
- $table .= "
- $table .= "
- $table .= '
- }
- $table .= '
- $table .= '
';
id |
标题 |
电话 |
地址 |
审核状态 |
内容 |
留言时间 |
';
';
";
".$value['id'].' | ';
".$value['title'].' | ';
".$value['phone'].' | ';
".$value['address'].' | ';
".$value['ischeck'].' | ';
".$value['content'].' | ';
".substr($value['datetime'],0,11).' | ';
';
';
';
- echo $table;
- ?>
复制代码
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-08-21 20:44:13
-
2024-08-21 20:42:40
-
2024-08-21 20:42:03
-
2024-08-21 20:38:37
-
2024-08-21 20:38:34
-
2024-08-21 20:38:30
-
2024-08-21 20:36:20
-
2024-08-21 20:36:06
-
2024-08-21 20:36:00
-
2024-08-21 20:35:51