深圳全飞鸿
标题:
beacon的报表数据处理(excel)
[打印本页]
作者:
zhgc
时间:
2021-6-11 16:57
标题:
beacon的报表数据处理(excel)
beacon的报表数据处理(excel)
默认功能放在基类activity.inc.php的默认函数createExcel()中
//第五种情况的UI: 下载
if($this->editgrid_action=="download"){
__saveLog("执行download页面UI");
$this->loadLastQuery();
$this->showReport();
$this->createExcel();
$this->halt=true;
return;
}
复制代码
默认的下载处理函数:
/*
* 下载Excel数据;
*/
function createExcel(){
global $db, $config, $user, $report, $smarty;
$sqlstr = $smarty->tpl_vars["sql"];
$limit = 65000; //最大60K
//require_once("phar://beacon.inc.phar/page.inc.php");
include_once("page.inc.php");
$pager = new pager($limit, 1);
$data=$pager->execute($db, $sqlstr);
$count=count($data); //数量
include_once("excel.inc.php");
if($count==0){
//die( $sqlstr);
ob_end_clean(); //fix by syant !
exportExcel($report->Title, array(''), array(array(''),array('')), '', './', true);
}else if($count>60000){
//die( "a".$sqlstr);
ob_end_clean(); //fix by syant !
exportExcel($report->Title, array('警告'), array(array('由于数据量超过60000,请联系管理人员!'),array($sqlstr)), '', './', true);
}else{
$col=array_keys($data[0]);
$line=array();
foreach($data as $v){
$line[]=array_values($v);
}
ob_end_clean(); //fix by syant !
exportExcel($report->Title, $col, $line, '', './', true);
//exportExcel("syant-test",array('AA','BB'), array(array('a',21),array('b',23)), 'test', './', true);
}
}
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2