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 ...
随机推荐
- MySQL 基础--时间戳类型
时间戳数据存储 .TimeStamp的取值范围为'1970-01-01 00:00:01' UTC 至'2038-01-19 03:14:07' UTC: .在存储时间戳数据时先将数据转换为UTC时区 ...
- zabbix docker - 安装和初始化配置
zabbix docker - 安装和初始化配置 安装zabbix server docker-mysql版本 zabbix server支持不同的数据库(详见zabbix的docker hub),这 ...
- webrtc vad小bug
当channel为5的时候offset为80,再进行下面的操作smallest_values[j + 1]将会越出数组的限界到”第97个“:应该将下图的16改为15 low_value_vector数 ...
- python库函数Map, Filter and Reduce的用法
python中有三个函数式编程极大的简化了程序的复杂性,这里就做一下讨论和记录. 一 Map:应用在链表输入所有元素的函数,它的格式如下所示: map(function_to_apply, list_ ...
- Tools - VirtualBox的使用方法和技巧
01 - 为CentOS虚拟机安装VirtualBox增强功能 启动CentOS虚拟机,点击"菜单 -> 设备 -> 安装增强功能". vboxadd的映像文件将会被挂 ...
- SpringBoot初探(上传文件)
学了Spring,SpringMVC,Mybatis这一套再来看SpringBoot,心里只有一句握草,好方便 这里对今天做的东西做个总结,然后在这之间先安利一个热部署的工具,叫spring-DevT ...
- [每天解决一问题系列 - 0006] MSBuild 和Visual Studio并行编译
问题描述: 有的项目会有上百个.net工程,编译时间会很长,如何缩短编译的时间呢? 解决方法: 如果使用MSbuild, 指定/maxcpucount 或者/m,如果不指定值,则取当前机器逻辑CPU的 ...
- 课程四(Convolutional Neural Networks),第二 周(Deep convolutional models: case studies) —— 2.Programming assignments : Keras Tutorial - The Happy House (not graded)
Keras tutorial - the Happy House Welcome to the first assignment of week 2. In this assignment, you ...
- Hadoop项目实战-用户行为分析之编码实践
1.概述 本课程的视频教程地址:<用户行为分析之编码实践> 本课程以用户行为分析案例为基础,带着大家去完成对各个KPI的编码工作,以及应用调度工作,让大家通过本课程掌握Hadoop项目的编 ...
- tls1.2 rfc5246
注:本文省略了部分开发协议才涉及到的内容,如字段类型的定义以及字段长度的运算,主要聚焦理解tls协议的运作方式,用于问题定位 tls协议包含2层协议:TLS Record 协议和TLS Handsha ...