php7.27: export excel from mysql
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的更多相关文章
- python2.7爬取豆瓣电影top250并写入到TXT,Excel,MySQL数据库
python2.7爬取豆瓣电影top250并分别写入到TXT,Excel,MySQL数据库 1.任务 爬取豆瓣电影top250 以txt文件保存 以Excel文档保存 将数据录入数据库 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 ...
- python3爬取”理财大视野”中的股票,并分别写入txt、excel和mysql
需求:爬取“理财大视野”网站的排名.代码.名称.市净率.市盈率等信息,并分别写入txt.excel和mysql 环境:python3.6.5 网站:http://www.dashiyetouzi.co ...
- export excel
export excel sheet.js https://sheetjs.com/ https://github.com/SheetJS/sheetjs excel.js https://www.n ...
- PHP7.27: connect mysql 5.7 using new mysqli_connect
<!doctype html> <html> <head> <meta name="viewport" content="wid ...
- PHP7.27: connect mysql 5.7 using new mysqli
<!doctype html> <html> <head> <meta name="viewport" content="wid ...
- Export Data from mysql Workbench 6.0
原文地址:export-data-from-mysql-workbench-6-0 问题描述 I'm trying to export my database, using MySQL Workben ...
- javascript export excel
<input type="button" onclick="tableToExcel('tablename', 'name')" value=" ...
- CentOS下PHP7的编译安装,MySQL的支持和一些问题的解决
最近试了一下PHP7,在编译和支持MySQL上都遇到一些问题,相信不少同学也同样遇到,所以在这里聊一下这个过程.简单来讲编译PHP7只需要3步: 1../buildconf --force 2../c ...
随机推荐
- Asp.Net Core 禁用预编译
在.NET Core 2 Web API应用程序中,MS VS 2017中的发布到文件夹功能产生: <ProjectAssembly>.PrecompiledViews.dll <P ...
- Go语言数据类型
目录 基本数据类型说明 整型 浮点型 字符 字符类型本质探讨 布尔型 字符串 指针 值类型与引用类型 基本数据类型默认值 基本数据类型相互转换 注意事项 其他基本类型转string类型 string类 ...
- 在Markdown中写注释
概述 下面是我整理的在Markdown中写注释的几种方法,供自己开发时参考,相信对其他人也有用. html标签 既然Markdown内嵌html语法,那么就可以用可以用隐藏的html标签. 注意:需要 ...
- 开源性能测试工具Locust使用篇(二)
那如何理解Locust和TaskSet这两个类呢? class HttpLocust(Locust) 在Locust类中,具有一个client属性,它对应着虚拟用户作为客户端所具备的请求能力,也就是我 ...
- PHP画矩形,椭圆,圆,画椭圆弧 ,饼状图
1:画矩形: imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col ) imagere ...
- Servlet-获取页面的元素的值的方式以及区别
request.getParameter() 返回客户端的请求参数的值:request.getParameterNames() 返回所有可用属性名的枚举: request.getParameterVa ...
- web自动化测试---第一个自动化测试用例
测试环境搭建好之后就可以写自动化测试脚本了,我们以baidu为例,写一个自动化测试脚本 from selenium import webdriver import time driver = webd ...
- NFS客户端挂载
关于NFS挂载#卸载: umount -fl /挂载名称#重新挂载:mount -t nfs -o rw,noac 10.8.16.11:/vx/SJOA-APP /挂载名称 #mount –v查看当 ...
- HW2017笔试编程题
一.写一个转换字符串的函数 1.题目描述 将输入字符串中下标为偶数的字符连成一个新的字符串输出,需要注意两点: (1)如果输入字符串的长度超过20,则转换失败,返回“ERROR!”字符串: (2)输入 ...
- BF算法(模式匹配)
BF算法 (Brute-Force算法) 一种简单的模式匹配算法,目的是寻找模式串p是否在目标串s中有出现. 思想:先从第一个字符开始匹配,如果p[j]==s[i],那么继续向下比较,一旦不相等,即回 ...