https://stackoverflow.com/questions/15699301/export-mysql-data-to-excel-in-php

https://github.com/PHPOffice

https://www.ibm.com/developerworks/library/os-phpexcel/index.html

<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>execl</title>
<meta name="keywords" content="geovindu">
<meta name="description" content="涂聚文">
</head> <body>
<?php
$servername = "localhost"; //127.0.0.1:3306
$username = "root";
$password = "8888";
$dbname = "sakila";
//mysql and db connection $con = new mysqli($servername, $username, $password, $dbname); if ($con->connect_error) { //error check
die("Connection failed: " . $con->connect_error);
}
else
{ } $DB_TBLName = "dt_sample";
$filename = "geovindu"; //your_file_name
$file_ending = "utf-8"; //file_extention
header("Content-Type: application/vnd.ms-excel;charset=utf-8");
//header("Content-Type: application/xls");
//header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0"); $sep = "\t"; $sql="SELECT * FROM dt_sample";
$resultt = $con->query($sql);
print("<table><tr>");
while ($property = mysqli_fetch_field($resultt)) { //fetch table field name
echo "<td>".$property->name."</td>";
}
print("</tr>"); while($row = mysqli_fetch_row($resultt)) //fetch_table_data
{
print("<tr>");
$schema_insert = "";
for($j=0; $j< mysqli_num_fields($resultt);$j++)
{
if(!isset($row[$j]))
$schema_insert .="<td>". "NULL".$sep."</td>";
elseif ($row[$j] != "")
$schema_insert .="<td>"."$row[$j]".$sep."</td>";
else
$schema_insert .= "<td>".$sep."</td>";
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
//$schema_insert .= "</tr>";
print(trim($schema_insert));
print("</tr>");
}
print "</table>";
?>
</body>
</html>

  

php7.27: export excel from mysql的更多相关文章

  1. python2.7爬取豆瓣电影top250并写入到TXT,Excel,MySQL数据库

    python2.7爬取豆瓣电影top250并分别写入到TXT,Excel,MySQL数据库 1.任务 爬取豆瓣电影top250 以txt文件保存 以Excel文档保存 将数据录入数据库 2.分析 电影 ...

  2. How to export Excel files in a Python/Django application

    https://assist-software.net/blog/how-export-excel-files-python-django-application CONTENTS Introduct ...

  3. python3爬取”理财大视野”中的股票,并分别写入txt、excel和mysql

    需求:爬取“理财大视野”网站的排名.代码.名称.市净率.市盈率等信息,并分别写入txt.excel和mysql 环境:python3.6.5 网站:http://www.dashiyetouzi.co ...

  4. export excel

    export excel sheet.js https://sheetjs.com/ https://github.com/SheetJS/sheetjs excel.js https://www.n ...

  5. PHP7.27: connect mysql 5.7 using new mysqli_connect

    <!doctype html> <html> <head> <meta name="viewport" content="wid ...

  6. PHP7.27: connect mysql 5.7 using new mysqli

    <!doctype html> <html> <head> <meta name="viewport" content="wid ...

  7. Export Data from mysql Workbench 6.0

    原文地址:export-data-from-mysql-workbench-6-0 问题描述 I'm trying to export my database, using MySQL Workben ...

  8. javascript export excel

    <input type="button" onclick="tableToExcel('tablename', 'name')" value=" ...

  9. CentOS下PHP7的编译安装,MySQL的支持和一些问题的解决

    最近试了一下PHP7,在编译和支持MySQL上都遇到一些问题,相信不少同学也同样遇到,所以在这里聊一下这个过程.简单来讲编译PHP7只需要3步: 1../buildconf --force 2../c ...

随机推荐

  1. 微服务日志之.NET Core使用NLog通过Kafka实现日志收集

    一.前言 NET Core越来越受欢迎,因为它具有在多个平台上运行的原始.NET Framework的强大功能.Kafka正迅速成为软件行业的标准消息传递技术.这篇文章简单介绍了如何使用.NET(Co ...

  2. 696. Count Binary Substrings

    Give a string s, count the number of non-empty (contiguous) substrings that have the same number of ...

  3. shell if 条件判断

    condition='123' if [ -z condition]; then echo "condition 是空的" fi 字符串判断: = 两个字符串相等. != 两个字符 ...

  4. USB插入电脑的硬件检测和枚举流程

    USB协议定义了设备的6种状态,仅在枚举过程种,设备就经历了4个状态的迁移:上电状态(Powered),默认状态(Default),地址状态(Address)和配置状态(Configured)(其他两 ...

  5. C语言判断大小端的几种方法

    在操作系统中,经常会用到判断大小端,很多面试题中也会经常遇到,以前的时候没有总结过,这里总结一下. 以后用到了就直接可以用了. 所谓的大小端,大致的解释意思就是: [大端模式] CPU对操作数的存放方 ...

  6. 转载 用Python实现设计模式——工厂模式

    转载自 SegmentFault作者 夏秋, https://segmentfault.com/a/1190000013053013 非常感谢这位作者的深入浅出的讲解. 前言 工厂模式,顾名思义就是我 ...

  7. ReentrantLock实现原理分析

    ReentrantLock主要利用CAS+CLH队列来实现.它支持公平锁和非公平锁,两者的实现类似. CAS:Compare and Swap,比较并交换.CAS有3个操作数:内存值V.预期值A.要修 ...

  8. 树莓派安装vnc server并设置自启动

    在SSH终端输入sudo raspi-config, 这里需要打开几个选项: expand_rootfs – 将根分区扩展到整张SD卡; change_pass – 默认的用户名是pi,密码是rasp ...

  9. PostgreSQL查询优化逻辑优化之其他

    上一节我们介绍了PostgreSQL的子查询优化,子查询优化把一部分可以优化的子查询上拉到主查询成为join. preprocess_expression 将表达式(目标列,where,join,ha ...

  10. 【源码解读】EOS测试插件:txn_test_gen_plugin.cpp

    本文内容本属于<[精解]EOS TPS 多维实测>的内容,但由于在编写时篇幅过长,所以我决定将这一部分单独成文撰写,以便于理解. 关键字:eos, txn_test_gen_plugin, ...