php导出excel(xls或xlsx)
$titles = array('订单号','商品结算码','合同号','供应商名称','专柜','商品名称','商品货号','商品单价','商品总价','供应商结算金额','商品数量','商品促销优惠','平台优惠抵扣','品牌订单优惠抵扣');
//导出准备
ob_get_clean();
ob_start();
echo implode("\t", $titles),"\n";
$currencyModel = app::get('ectools')->model('currency');
foreach ($lists as $key=>$value) {
$row = array();
$row['order_id'] = html_entity_decode("".$value['order_id']);
$row['supplier_num'] = $value['supplier_num'];
$row['agreement_code'] = $value['agreement_code'];
$row['supplier_name'] = $value['supplier_name'];
$row['shoppe_name'] = $value['shoppe_name'];
$row['name'] = $value['name'];
$row['bn'] = $value['bn'];
$row['price'] = $value['price'];
$row['nums'] = $value['nums'];
$row['g_price'] = $value['g_price'];
$row['settlement_amount'] = $value['settlement_amount'];
$row['goods_amount_off'] = $value['goods_amount_off'];
$row['amount_off'] = $value['amount_off'];
$row['brand_amount_off'] = $value['brand_amount_off'];
echo implode("\t", $row),"\n";
}
header('Content-Disposition: attachment; filename='.$filename);
header('Accept-Ranges:bytes');
header('Content-Length:' . ob_get_length());
header('Content-Type:application/vnd.ms-excel');
ob_end_flush();
2)格式选择
需要导出xls的话,用
header('Content-Type:application/vnd.ms-excel');
需要导出xlsx的话,用
header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
xls和xlsx的区别的话,是储存数据量大小的问题,xls只可以保存大概5、6w数据,xlsx可以100w左右
3)长数字完整显示解决办法
$row['order_id'] = html_entity_decode("".$value['order_id']);
转: https://www.cnblogs.com/tujia/p/5999806.html
download.php下载
<?php
//获取要下载的文件名
$filename = $_GET['filename'];
//设置头信息
header('Content-Disposition:attachment;filename=' . basename($filename));
header('Content-Length:' . filesize($filename));
//读取文件并写入到输出缓冲
readfile($filename);
https://www.cnblogs.com/xiaopiyuanzi/p/7243051.html
php导出excel(xls或xlsx)的更多相关文章
- POI导出Excel(xls、xlsx均可以,也支持图片)——(三)
Jar包
- C# 将DataGridView中显示的数据导出到Excel(.xls和.xlsx格式)—NPOI
前言 https://blog.csdn.net/IT_xiao_guang_guang/article/details/104217491 本地数据库表中有46785条数据,测试正常 初次运行程 ...
- C# 操作 Excel(.xls和.xlsx)文件
C#创建Excel(.xls和.xlsx)文件的三种方法 .NET 使用NPOI导入导出标准Excel C# 使用NPOI 实现Excel的简单导入导出 NET使用NPOI组件将数据导出Excel-通 ...
- C# EXCEL(.xls和.xlsx)导入到数据库
C# EXCEL(.xls和.xlsx)导入到数据库 转(http://www.cnblogs.com/bart-cai/articles/2716555.html) 原理:1.判断是否是Excel ...
- python pandas合并多个excel(xls和xlsx)文件(弹窗选择文件夹和保存文件)
# python pandas合并多个excel(xls和xlsx)文件(弹窗选择文件夹和保存文件) import tkinter as tk from tkinter import filedial ...
- 使用NPOI导入导出Excel(xls/xlsx)数据到DataTable中
using System; using System.Collections.Generic; using System.Text; using System.IO; using NPOI.SS.Us ...
- winfrom 使用NPOI导入导出Excel(xls/xlsx)数据到DataTable中
1.通过NUGET管理器下载nopi,在引入命令空间 using System; using System.Collections.Generic; using System.Text; using ...
- java poi导出EXCEL xls文件代码
String _currentPage = request.getParameter("currentPage"); Integer currentPage = 0; if(_cu ...
- POI读取Excel(xls、xlsx均可以)——(四)
maven构建的项目-->pom.xml文件 eclipse提供Dependencies直接添加依赖jar包的工具:直接搜索poi以及poi-ooxml即可,maven会自动依赖需要的jar包: ...
- 如何使用Java创建Excel(.xls 和 .xlsx)文件 并写入数据
1,需要依赖的jar包, <!-- POI(operate excel) start --> <!-- the version of the following POI packag ...
随机推荐
- Java 中 Map 的使用
Map接口提供了一组能够以键-值对(key,value)形式存储的数据结构. Map对存入元素仅仅有一个要求.就是键(key)不能反复,Map对于key.value要求不是非常严格,key仅仅要是引用 ...
- [Algorithm] Largest sum of non-adjacent numbers
Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Num ...
- Ejb in action(一)——开篇介绍
从今天開始.我们共同来学习JavaEE中一个很重要的规范:Ejb. 既然您已经找到了这篇文章.就说明您至少已经对分布式开发有个大体上的概念了,之前没了解过也没关系,正好通过咱们的共同学习,一起来了解它 ...
- sqoop安装部署(笔记)
sqoop是一个把关系型数据库数据抽向hadoop的工具.同时,也支持将hive.pig等查询的结果导入关系型数据库中存储.由于,笔者部署的hadoop版本是2.2.0,所以sqoop的版本是:sqo ...
- C#.NET常见问题(FAQ)-如何生成release版本的程序,生成debug版本的程序
除了右击项目在生成中配置改成Release还要在顶部切换成Release 更多教学视频和资料下载,欢迎关注以下信息: 我的优酷空间: http://i.youku.com/acetaohai1 ...
- HDU 1199 && ZOJ 2301 线段树离散化
一段长度未知的线段.一种操作:a b c ,表示区间[a,b]涂为颜色C,w代表白色,b代表黑色,问终于的最长连续白色段,输出起始位置和终止位置 离散化处理.和寻常的离散化不同,须要把点化成线段.左闭 ...
- cocos2d 重写顶点着色语言
bool CCShaderSprite::initWithFile( const char *pszFilename ) { bool ret=false; do { ret=CCSpri ...
- HTML字符实体举例说明
html代码的意思 <>& ©∧∨"&qpos; 下面网址有详细说明: http://en.wikipedia.org/wiki/List_of_XML_and_ ...
- Oracle内存管理(之二)
[深入解析--eygle] 学习笔记 1.2.2 UGA和CGA UGA(用户全局区)由用户会话数据.游标状态和索引区组成.在共享server模式下,一个共享服务进程被多个用户进程共享,此时UGA是S ...
- GitLab Notification Emails
GitLab has a notification system in place to notify a user of events that are important for the work ...