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体系结构和存储引擎概述
MySQL体系结构和存储引擎概述 一.定义数据库和实例 数据库: 物理操作系统文件或其他形式文件类型的集合.数据库文件可以是frm.MYD.ibd 结尾的文件. 从概念上来说,数据库是文件的集合,是 ...
- Java学习笔记36(File类)
File类可以对操作系统中的文件进行操作: File类的静态成员变量: package demo; import java.io.File; public class FileDemo { publi ...
- Swift5 语言指南(七) 集合类型
Swift提供三种主要的集合类型,称为数组,集合和字典,用于存储值集合.数组是有序的值集合.集是唯一值的无序集合.字典是键值关联的无序集合. Swift中的数组,集合和字典总是清楚它们可以存储的值和键 ...
- Java 项目UML反向工程转化工具
今天在看一个模拟器的源码,一个包里有多个类,一个类里又有多个属性和方法,如果按顺序看下来,不仅不能对整个模拟器的框架形成一个大致的认识,而且只会越看越混乱,所以,想到有没有什么工具可以将这些个类以及它 ...
- python学习记录(一)
1.打印操作 >>> print('hello') hello >>> print(1+2) 3 2.字符串操作 ① ') Traceback (most rece ...
- jenkins配置邮件 -- com.sun.mail.smtp.SMTPSenderFailedException: 550 5.7.1 Client does not have permissions to send as this sender
jenkins配置邮件设置 发送邮件测试时,报错: com.sun.mail.smtp.SMTPSenderFailedException: Client does not have permissi ...
- Java连接Mysql数据库警告: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established
详细错误: Establishing SSL connection without server's identity verification is not recommended. Accordi ...
- PowerShell 连接远程服务器
>>服务端Enable-PSRemoting winrm quickconfig ————这个可能不需要 >>客户端Set-Item wsman:\localhost\Clie ...
- Atom相关资料整理
官网地址 https://atom.io/ Atom 中文社区 https://atom-china.org/ 常用插件 Emmet 这款插件是用来支持zend-coding,Emmet的前身是大名鼎 ...
- 使用Spring Boot开发 “Hello World” Web应用
环境准备 由于现在很多IDE都支持Maven, 所以我们将使用Maven构建该工程: 开始之前,需要先安装Java和Maven: 本工程将基于Spring Boot 1.4.3.RELEASE开发,推 ...