深圳全飞鸿
标题:
关于PHP下载为Excel的解决方案: DCC-0005-0004-0004-0002
[打印本页]
作者:
admin
时间:
2019-6-18 00:19
标题:
关于PHP下载为Excel的解决方案: DCC-0005-0004-0004-0002
关于下载为Excel的解决方案
作者:
zhgc
时间:
2021-6-11 17:04
关于下载为Excel的解决方案
首先,验证环境
http://192.168.0.254/sfc/e.php
<?php
include_once("excel.inc.php");
exportExcel("syant-test",
array('姓名','年龄'),
array(array('a',21),array('b',23)),
'test', './', true);
复制代码
如果可行,则进行第二步检测:
http://192.168.0.254/sfc/ee.php
<?php
include_once("excel.inc.php");
require_once("config.inc.php");
$config = new config(); //定义全局变量1
$config->db_host="192.168.0.254";
include_once("libs/mi.adodb.php");
$db = dbconn($config->db_host, $config->db_username, $config->db_password, $config->db_database, $config->db_type);
$sqlstr = "select * from sfc.c_line_desc_t";
$limit = 65000; //最大60K
require_once("page.inc.php");
$pager = new pager($limit, 1);
$data=$pager->execute($db, $sqlstr);
$count=count($data); //数量
include_once("excel.inc.php");
$col=array_keys($data[0]);
$line=array();
foreach($data as $v){
$line[]=array_values($v);
}
exportExcel("syant-test", $col, $line, '', './', true);
复制代码
fix bug:
ob_end_clean(); //fix by syant !
header('pragma:public');
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2