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. java.io.IOException: No space left on device 错误

    今天碰到比较奇怪的问题: 7/05/14 19:20:24 INFO util.Utils: Fetching http://192.168.31.160:33039/jars/spark_study ...

  2. php开发中应该注意的错误开关与常见处理[开发篇]

    我们可能一开始就接触一个项目的开发,刚开始时都是信心满满,一定把这个项目做得非常完美,但是时间那么少,任务那么多,我们就只有将就了. 首先,一般情况下,我们会加一个调试标志,define('APP_D ...

  3. Spring 源码分析之 bean 依赖注入原理(注入属性)

         最近在研究Spring bean 生命周期相关知识点以及源码,所以打算写一篇 Spring bean生命周期相关的文章,但是整理过程中发现涉及的点太多而且又很复杂,很难在一篇文章中把Spri ...

  4. Spring 异常处理三种方式 @ExceptionHandler

    异常处理方式一. @ExceptionHandler 异常处理方式二. 实现HandlerExceptionResolver接口 异常处理方式三. @ControllerAdvice+@Excepti ...

  5. Redis主从和集群

    主从概念 一个master可以拥有多个slave,一个slave又可以拥有多个slave.如此下去,形成了强大的多级服务器集群架构. master用写数据,经统计:网站的读写比率是10:1 通过主从分 ...

  6. 关于iscroll插件的使用

    本次项目有一个需要多信息展示,需要左右滑动的效果,查资料了解到iscroll,就拿来用,如下调用: var myscroll = new IScroll("#wrapper", { ...

  7. Python:标准库(包含下载地址及书本目录)

    下载地址 英文版(文字版) 官方文档 The Python Standard Library <Python标准库>一书的目录 <python标准库> 译者序 序 前言 第1章 ...

  8. python中selenium操作下拉滚动条方法汇总

    UI自动化中经常会遇到元素识别不到,找不到的问题,原因有很多,比如不在iframe里,xpath或id写错了等等:但有一种是在当前显示的页面元素不可见,拖动下拉条后元素就出来了. 比如下面这样一个网页 ...

  9. Oracle的数据并发与一致性详解(上)

    今天想了解下oracle中事务与锁的原理,但百度了半天,发现网上介绍的内容要么太短,要么版本太旧,而且抄袭现象严重,所以干脆查官方帮助文档(oracle 11.2),并将其精华整理成中文,供大家一起学 ...

  10. Kafka实战-入门

    1.概述 经过一个多月的时间观察,业务上在集成Kafka后,各方面还算稳定,这里打算抽时间给大家分享一下Kafka在实际场景中的一些使用心得.本篇博客打算先给大家入个门,让大家对Kafka有个初步的了 ...