当前位置:网站首页>php+mysql导出excel文件方法
php+mysql导出excel文件方法
2022-07-24 05:18:00 【amogogo12】
怎么用php+mysql打印数据这块不多说了。只说数据怎么导出到excel
ob_end_clean();//
$file_name='数据.xls';
$userBrowser = $_SERVER['HTTP_USER_AGENT'];
if ( preg_match( '/MSIE/i', $userBrowser ) ) {
$filename = urlencode($filename);
}
$filename = iconv('UTF-8', 'gb2312', $filename);
header("<meta http-equiv='X-UA-Compatible' content='IE=Edge'>");
header("<meta http-equiv='content-type' content='text/html;charset=uft-8'>");
header("Content-Type: application/vnd.ms-excel");
header("Expires:0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename={
$file_name}");
header( "Cache-Control: public" );
header( "Pragma: public" );
header( "Content-type: text/csv" ) ;
header( "Content-Dis; filename={
$file_name}" ) ;
echo "姓名"."\t";
echo "电话"."\t";
echo "\t\n";
$dsql->SetQuery($sql);//将SQL查询语句格式化
$dsql->Execute();//执行SQL操作
//这里通过循环输出执行查询中的结果。可以根据你的程序循环出数据
while($row = $dsql->GetArray()){
echo $row['title']."\t";
echo $row['tel']."\t";
echo "\t\n";
}
这个导出的数据,类似csv格式的,用wps打开没问题。
仅供参考
边栏推荐
- 9.使用网格技术,在屏幕上绘制一个五角形。
- 收藏==学废
- Promise_async与await
- 网页内嵌B站视频,隐藏相关控件
- day(0~6)代表每月第一天起始位置,stop代表每月天数,每天之间空两个空格。输入不同的day和stop,输出每月日历的样子。假设day为2,stop为31,则输出样式为
- [common skills]
- Draw a circle and a square on the screen. The square is in front and the circle is behind. You can move the square through the keyboard. In the following cases, the square can only move within the cir
- libc.so.6/glibc交叉编译
- Keywords_ 02break and continue
- JS - 鼠标键盘配置 及 浏览器禁止操作
猜你喜欢
随机推荐
OpenGL draws two points on the screen, a blue point on the right, using anti aliasing technology, and a red point on the left, without anti aliasing technology. Compare the difference between the two
输入10个人的名字,按从大到小排序输出
微信小程序报错request:fail -2:net::ERR_FAILED
Scope and scope chain
[common skills]
Draw a moving teapot on the screen. The teapot first moves slowly towards the screen, becoming smaller and smaller, becoming more and more blurred; Then it grows bigger and clearer, and keeps repeatin
day(0~6)代表每月第一天起始位置,stop代表每月天数,每天之间空两个空格。输入不同的day和stop,输出每月日历的样子。假设day为2,stop为31,则输出样式为
Opengl模拟现实生活中,球掉到地面上再弹起来的过程,在屏幕上绘制一个球,球从上往下掉,碰到地面,再弹起来。
一文node安装下载和配置
Ain 0722 sign in
02-移动端页面适配
OpenGL draws a cone on the screen, which has four faces, each of which is a triangle. Add lighting and texture effects to the cone
libc.so.6/glibc交叉编译
9.使用网格技术,在屏幕上绘制一个五角形。
Promise_ Async and await
ros启动非本机节点
Find the flops of the network
sunset: noontide靶机渗透-vulnhub
MySQL之CRUD
key的作用是什么









