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 ...
随机推荐
- chm格式文件,win7下用c:/windows/hh.exe打开
chm格式文件,win7下用c:/windows/hh.exe打开
- [Algorithm] Universal Value Tree Problem
A unival tree (which stands for "universal value") is a tree where all nodes under it have ...
- tiny210(s5pv210)移植u-boot(基于 2014.4 版本号)——移植u-boot.bin(打印串口控制台)
在之前我们移植的代码中,都没看到明显的效果,这节我们实现控制台的信息打印. 在上节.我们看到调用 relocate_code 重定位.在 u-boot 的帮助文档 doc/README.arm-rel ...
- 一段遍历4X4表格,取出每个单元格内容组合成文本的JS代码
遍历表格的JS容易忘,留个随笔以备忘. var tableData=""; var table=document.getElementById("XXTableId ...
- MyEclipse开发Rest服务入门
MyEclipse支持Rest服务,开发起来非常方便,下面我就举一个计算机的例子: 实现功能:加.减.乘.除: 效果如下: Rest服务要点:每个服务或任何东西都有一个URI: 步骤1:创建Web S ...
- PHP高级教程-JSON
PHP JSON 本章节我们将为大家介绍如何使用 PHP 语言来编码和解码 JSON 对象. 环境配置 在 php5.2.0 及以上版本已经内置 JSON 扩展. JSON 函数 函数 描述 json ...
- 栈的应用实例——平衡符号
检查().[].{}是否配对. /* stack_balance_symbol */ #include "stack.h" #include <stdio.h> #in ...
- Android的startActivityForResult不起作用
之前startActivityForResult一直用的好好的,今天发现怎么也不起作用.检查后发现有两点影响了. 1.android:launchMode="singleTask" ...
- SQLAlchemy数据类型
- systemctl的常用命令
#systemctl #systemctl --all #systemctl list-units --type=sokect #systemctl list-units --type=service ...