/** * * @do game数据统计 导出 * * @access public * @author Nick * @copyright rockhippo * @param - * @return - * */ public function getactivitydataoutputAction() { $result = $this->getactivitydataAction(true); $XPhpExcel = new XPhpExcel(); $Creator = "adm.wonaonao.com"; $LastModifiedBy = $Creator; $Title = '交运活动数据统计'; $Subject = '交运活动数据统计'; $Description = '交运活动数据统计'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "车号"); //$XPhpExcel->setWidth("A",14,2); $XPhpExcel->setValue("B1", '日期'); $XPhpExcel->setValue("C1", '活动'); $XPhpExcel->setValue("D1", '点击次数'); $XPhpExcel->setValue("E1", 'iOS'); $XPhpExcel->setValue("F1", 'Android'); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 25, 2); $XPhpExcel->setWidth("C", 20, 2); $XPhpExcel->setWidth("D", 20, 2); $XPhpExcel->setWidth("E", 15, 2); $XPhpExcel->setWidth("F", 15, 2); $bmanyday = $bday = reqstr("bmanyday"); $emanyday = $eday = reqstr("emanyday"); if ($bmanyday && !$emanyday) { $time = $bday; } elseif (!$bmanyday && $emanyday) { $time = $eday; } elseif ($bmanyday && $emanyday) { $time = $bday . " ~ " . $eday; } $num = 1; foreach ($result as $key2 => $val2) { foreach ($val2 as $key => $val) { $XPhpExcel->setValue('A' . ($num + 1), $val['number']); $XPhpExcel->setValue('B' . ($num + 1), $time); $XPhpExcel->setValue('C' . ($num + 1), $val['activityname']); $XPhpExcel->setValue('D' . ($num + 1), $val['click']); $XPhpExcel->setValue('E' . ($num + 1), $val['ios']); $XPhpExcel->setValue('F' . ($num + 1), $val['android']); $num++; } } //清空输出缓存 ob_clean(); $XPhpExcel->output($time . "/" . $Description); unset($XPhpExcel); //销毁 }
/** * * @do 导出excel * * @access public * @author Nick * @copyright rockhippo * @param - * @return - * */ public function ajaxOutputExcelAction() { $wordArr = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); $PSys_AccessModel = new PSys_AccessModel(); //站点数据 $where = array(); $order = "id ASC"; $field = "id,stationname"; $PSys_AccessModel = new PSys_AccessModel(); $station = $PSys_AccessModel->GetList($where, $order, 0, 0, $field, "rha_station"); $fastSearch = reqnum("fastSearch", 0); //快速查询 $dataStatusFS = reqnum("datastatusFS", 1); //快速查询合并、比较筛选按钮 1为合并 2为比较 默认合并 $xv = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); switch ($fastSearch) { case 1: //当天 $date = date("Y-m-d"); $data = array(); if ($dataStatusFS == 1) { $group = "`hour`"; $dbname = "rha_aclog_hour"; $result = $PSys_AccessModel->getDay($date, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本日-合并'; $Description = '访问统计-访问人数(本日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "小时"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`hour`,`stationid`"; $dbname = "rha_aclog_hour"; $result = $PSys_AccessModel->getDay($date, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本日-比较'; $Description = '访问统计-访问人数(本日-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "小时"); for ($i = 0; $i < count($xv); $i++) { $XPhpExcel->setValue("A" . ($i + 2), $i); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['stationid']][$val['date']] = $val['total']; } foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < count($xv); $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][$xv[$i]]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } break; case 2: //本周 $date = date("Y-m-d"); $bdate = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1, date("Y"))); $edate = date("Y-m-d", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"))); $data = array(); if ($dataStatusFS == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本周-合并'; $Description = '访问统计-访问人数(本周-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本周-比较'; $Description = '访问统计-访问人数(本周-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 14, 2); for ($i = 0; $i < 7; $i++) { $XPhpExcel->setValue("A" . ($i + 2), date("Y-m-d", strtotime("{$bdate} +{$i} day"))); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < 7; $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][date("Y-m-d", strtotime("{$bdate} +{$i} day"))]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } break; case 3: //本月 $bdate = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y"))); $edate = date("Y-m-d", mktime(23, 59, 59, date("m"), date("t"), date("Y"))); $date = date("Y-m"); $data = array(); if ($dataStatusFS == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本月-合并'; $Description = '访问统计-访问人数(本月-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '本月-比较'; $Description = '访问统计-访问人数(本月-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 14, 2); for ($i = 0; $i < date("t"); $i++) { $XPhpExcel->setValue("A" . ($i + 2), date("Y-m-d", strtotime("{$bdate} +{$i} day"))); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < date("t"); $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][date("Y-m-d", strtotime("{$bdate} +{$i} day"))]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } break; default: $dateSearch = reqstr("dateSearch", ""); $datastatus = reqnum("datastatus", 1); $stationC = reqstr("stationC"); $stationC = explode(",", $stationC); $stationChoice = array(); if ($stationC == array()) { //若为空则为不排除站点 foreach ($station['allrow'] as $key => $val) { $stationChoice[] = $val['id']; //选中的站点 } } else { foreach ($station['allrow'] as $key => $val) { if (in_array($val['id'], $stationC)) { $stationChoice[] = $val['id']; //选中的站点 } } } switch ($dateSearch) { case "oneday": $date = reqstr("oneday"); $data = array(); //x轴数据 $xv = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); if ($datastatus == 1) { $group = "`hour`"; $dbname = "rha_aclog_hour"; $result = $PSys_AccessModel->getDay($date, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单日-合并'; $Description = '访问统计-访问人数(单日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "小时"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`hour`,`stationid`"; $dbname = "rha_aclog_hour"; $result = $PSys_AccessModel->getDay($date, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单日-比较'; $Description = '访问统计-访问人数(单日-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "小时"); for ($i = 0; $i < count($xv); $i++) { $XPhpExcel->setValue("A" . ($i + 2), $i); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['stationid']][$val['date']] = $val['total']; } foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < count($xv); $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][$xv[$i]]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } break; case "manyday": $bdate = reqstr("bmanyday"); $edate = reqstr("emanyday"); //计算天数差 $Days = round((strtotime($edate) - strtotime($bdate)) / 3600 / 24); $data = array(); if ($datastatus == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多日-合并'; $Description = '访问统计-访问人数(多日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多日-比较'; $Description = '访问统计-访问人数(多日-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 14, 2); for ($i = 0; $i < $Days; $i++) { $XPhpExcel->setValue("A" . ($i + 2), date("Y-m-d", strtotime("{$bdate} +{$i} day"))); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } ////重过滤$station // $where = array(); // $where['id_IN'] = $stationChoice; // $order = "id ASC"; // $field = "id,stationname"; // $station = $PSys_AccessModel->GetList($where, $order, 0, 0, $field, "rha_station"); foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < $Days; $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][date("Y-m-d", strtotime("{$bdate} +{$i} day"))]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } break; case "oneweek": $day = reqstr("oneweek"); $edate = date('Y-m-d', strtotime("{$day} Sunday")); $bdate = date('Y-m-d', strtotime("{$edate} -6 days")); //计算天数差 $Days = round((strtotime($edate) - strtotime($bdate)) / 3600 / 24); $data = array(); if ($datastatus == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单周-合并'; $Description = '访问统计-访问人数(单周-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单周-比较'; $Description = '访问统计-访问人数(单周-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 14, 2); for ($i = 0; $i < 7; $i++) { $XPhpExcel->setValue("A" . ($i + 2), date("Y-m-d", strtotime("{$bdate} +{$i} day"))); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } ////重过滤$station // $where = array(); // $where['id_IN'] = $stationChoice; // $order = "id ASC"; // $field = "id,stationname"; // $station = $PSys_AccessModel->GetList($where, $order, 0, 0, $field, "rha_station"); foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < 7; $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][date("Y-m-d", strtotime("{$bdate} +{$i} day"))]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } break; case "manyweek": $bday = reqstr("bmanyweek"); $edate2 = date('Y-m-d', strtotime("{$bday} Sunday")); $bdate = date('Y-m-d', strtotime("{$edate2} -6 days")); $eday = reqstr("emanyweek"); $edate = date('Y-m-d', strtotime("{$eday} Sunday")); $bdate2 = date('Y-m-d', strtotime("{$edate} -6 days")); //计算周数差 $Weeks = round((strtotime($edate) - strtotime($bdate)) / 3600 / 24 / 7); $data = array(); if ($datastatus == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); foreach ($result as $key => $val) { $data[$val['date']] = $val['total']; } $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多周-合并'; $Description = '访问统计-访问人数(多周-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 25, 2); $XPhpExcel->setWidth("B", 20, 2); for ($i = 0; $i < $Weeks; $i++) { $num = 0; for ($j = 1; $j <= 7; $j++) { $day = $i * 7 + $j - 1; $dt = date("Y-m-d", strtotime("{$bdate} +{$day} day")); $num += $data[$dt]; if ($j == 1) { $d = date("Y/m/d", strtotime("{$bdate} +{$day} day")); } if ($j == 7) { $d .= ' - ' . date("m/d", strtotime("{$bdate} +{$day} day")); $XPhpExcel->setValue("A" . ($i + 2), $d); $XPhpExcel->setValue("B" . ($i + 2), $num); } } } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多周-比较'; $Description = '访问统计-访问人数(多周-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 25, 2); foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < $Weeks; $i++) { $num = 0; for ($j = 1; $j <= 7; $j++) { $day = $i * 7 + $j - 1; $dt = date("Y-m-d", strtotime("{$bdate} +{$day} day")); $num += $data[$val['id']][$dt]; if ($j == 1) { $d = date("Y/m/d", strtotime("{$bdate} +{$day} day")); } if ($j == 7) { $d .= ' - ' . date("m/d", strtotime("{$bdate} +{$day} day")); $XPhpExcel->setValue("A" . ($i + 2), $d); $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $num); } } } } //to do nick 2030 celeste //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } break; case "onemonth": $date = reqstr("onemonth"); $bdate = date("Y-m-01", strtotime($date)); $edate = date("Y-m-d", strtotime("{$bdate} +1 month -1 day")); $date = date("Y-m", strtotime($date)); $Days = date("t", strtotime($date)); $data = array(); if ($datastatus == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单月-合并'; $Description = '访问统计-访问人数(单月-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 14, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($result as $key => $val) { $XPhpExcel->setValue("A" . ($key + 2), $val["date"]); $XPhpExcel->setValue("B" . ($key + 2), $val["total"]); } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '单月-比较'; $Description = '访问统计-访问人数(单月-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 14, 2); for ($i = 0; $i < $Days; $i++) { $XPhpExcel->setValue("A" . ($i + 2), date("Y-m-d", strtotime("{$bdate} +{$i} day"))); } $data = array(); //遍历数据获取所需结构 foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } ////重过滤$station // $where = array(); // $where['id_IN'] = $stationChoice; // $order = "id ASC"; // $field = "id,stationname"; // $station = $PSys_AccessModel->GetList($where, $order, 0, 0, $field, "rha_station"); foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); for ($i = 0; $i < $Days; $i++) { //echo $wordArr[$val['id']].($i+2) . "~" . $data[$val['id']][$xv[$i]] . "<br>"; $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $data[$val['id']][date("Y-m-d", strtotime("{$bdate} +{$i} day"))]); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } break; case "manymonth": $bday = reqstr("bmanymonth"); $bdate = date("Y-m-01", strtotime($bday)); $eday = reqstr("emanymonth"); $edate = date("Y-m-d", strtotime("{$eday} +1 month -1 day")); //计算月数差 $Months = (date("Y", strtotime($eday)) - date("Y", strtotime($bday))) * 12 + (date("m", strtotime($eday)) - date("m", strtotime($bday))) + 1; for ($i = 0; $i < $Months; $i++) { $dateArr[$i] = date("Y-m", strtotime("{$bday} +{$i} month")); } $data = array(); if ($datastatus == 1) { $group = "date"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); foreach ($result as $key => $val) { $data[$val['date']] = $val['total']; } $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多月-合并'; $Description = '访问统计-访问人数(多月-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 25, 2); $XPhpExcel->setWidth("B", 20, 2); $day = 0; for ($i = 0; $i < $Months; $i++) { $nums = 0; $num = date("t", strtotime("{$bday} +{$i} month")); $d = date("Y-m-01", strtotime("{$bday} +{$i} month")); for ($j = 1; $j <= $num; $j++) { if ($j == 1) { $d = date("Y/m", strtotime("{$bday} +{$i} month")); $XPhpExcel->setValue("A" . ($i + 2), $d); } //echo $day."<br/>"; //$data['data'][1]['data'][] = intval($result[$i-1]['total']); $nums += $data[date("Y-m-d", strtotime("{$bday} +{$day} day"))]; $day++; } $XPhpExcel->setValue("B" . ($i + 2), $nums); } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } else { $group = "`date`,`station`"; $dbname = "rha_wifi_daily"; $result = $PSys_AccessModel->getWeek($bdate, $edate, $group, $dbname, $stationChoice); foreach ($result as $key => $val) { $data[$val['station']][$val['date']] = $val['total']; } $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '访问统计-访问人数'; $Subject = '多月-比较'; $Description = '访问统计-访问人数(多月-比较)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "日期"); $XPhpExcel->setWidth("A", 25, 2); foreach ($station['allrow'] as $key => $val) { $XPhpExcel->setValue($wordArr[$val['id']] . "1", $val['stationname'] . "/人数"); $XPhpExcel->setWidth($wordArr[$val['id']], 20, 2); $day = 0; for ($i = 0; $i < $Months; $i++) { $nums = 0; $num = date("t", strtotime("{$bday} +{$i} month")); $d = date("Y-m-01", strtotime("{$bday} +{$i} month")); for ($j = 1; $j <= $num; $j++) { if ($j == 1) { $d = date("Y/m", strtotime("{$bday} +{$i} month")); $XPhpExcel->setValue("A" . ($i + 2), $d); } //echo $day."<br/>"; //$data['data'][1]['data'][] = intval($result[$i-1]['total']); $nums += $data[$val['id']][date("Y-m-d", strtotime("{$bday} +{$day} day"))]; $day++; } $XPhpExcel->setValue($wordArr[$val['id']] . ($i + 2), $nums); } } //清空输出缓存 ob_clean(); $XPhpExcel->output($bdate . "~" . $edate . "/" . $Description); unset($XPhpExcel); //销毁 } break; } } }
/** * * @do 导出excel * * @comprehensive public * @author Nick * @copyright rockhippo * @param - * @return - * */ public function ajaxOutputExcelAction() { $wordArr = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); $PSys_ComprehensiveModel = new PSys_ComprehensiveModel(); //站点数据 $where = array(); $order = "id ASC"; $field = "id,stationname"; $PSys_ComprehensiveModel = new PSys_ComprehensiveModel(); $station = $PSys_ComprehensiveModel->GetList($where, $order, 0, 0, $field, "rha_station"); $fastSearch = reqnum("fastSearch", 0); //快速查询 $dataStatusFS = reqnum("datastatusFS", 1); //快速查询合并、比较筛选按钮 1为合并 2为比较 默认合并 $data['xv'] = array("访问WIFI", "广告1", "注册页", "注册(登陆)", "广告2", "访问首页", "下载火伴"); switch ($fastSearch) { case 1: //昨日 $date = date("Y-m-d", strtotime("-1 day")); $group = ""; $dbname = "rha_wifi_daily"; $step = 1; $_step[1] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $date = date("Y_m_d", strtotime("-1 day")); $group = ""; $dbname = "rha_count_record"; $step = 2; $_step[2] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 3; $_step[3] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 4; $_step[4] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 5; $_step[5] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 6; $_step[6] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 7; $_step[7] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '综合统计-流程综合统计'; $Subject = '昨日-合并'; $Description = '综合统计-流程综合统计(昨日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "流程"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 20, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($data['xv'] as $key => $val) { if ($_step[$key][0]['total'] != '') { $m = "(" . round($_step[$key + 1][0]['total'] / $_step[$key][0]['total'] * 100, 2) . "%)"; } $XPhpExcel->setValue("A" . ($key + 2), $val); $XPhpExcel->setValue("B" . ($key + 2), strval($_step[$key + 1][0]['total'] . $m . " ")); } //清空输出缓存 ob_clean(); $XPhpExcel->output(str_replace("_", "-", $date) . "/" . $Description); unset($XPhpExcel); //销毁 break; case 2: //本周 $date = date("Y-m-d"); $bdate = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1, date("Y"))); $edate = date("Y-m-d", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"))); if (date("N", strtotime($date)) == 1) { $data['error'] = 'WEEKNODATA'; break; } $group = ""; $dbname = "rha_wifi_daily"; $step = 1; $_step[1] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $bdate = date("Y_m_d", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1, date("Y"))); $edate = date("Y_m_d", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"))); $group = ""; $dbname = "rha_count_record"; $step = 2; $_step[2] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 3; $_step[3] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 4; $_step[4] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 5; $_step[5] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 6; $_step[6] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 7; $_step[7] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '综合统计-流程综合统计'; $Subject = '本周-合并'; $Description = '综合统计-流程综合统计(本周-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "流程"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 20, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($data['xv'] as $key => $val) { if ($_step[$key][0]['total'] != '') { $m = "(" . round($_step[$key + 1][0]['total'] / $_step[$key][0]['total'] * 100, 2) . "%)"; } $XPhpExcel->setValue("A" . ($key + 2), $val); $XPhpExcel->setValue("B" . ($key + 2), strval($_step[$key + 1][0]['total'] . $m . " ")); } //清空输出缓存 ob_clean(); $XPhpExcel->output(str_replace("_", "/", $bdate) . "~" . str_replace("_", "/", $edate) . "/" . $Description); unset($XPhpExcel); //销毁 break; case 3: //本月 $bdate = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y"))); $edate = date("Y-m-d", mktime(23, 59, 59, date("m"), date("t"), date("Y"))); $date = date("Y-m"); $group = ""; $dbname = "rha_wifi_daily"; $step = 1; $_step[1] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $bdate = date("Y_m_d", mktime(0, 0, 0, date("m"), 1, date("Y"))); $edate = date("Y_m_d", mktime(23, 59, 59, date("m"), date("t"), date("Y"))); $group = ""; $dbname = "rha_count_record"; $step = 2; $_step[2] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 3; $_step[3] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 4; $_step[4] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 5; $_step[5] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 6; $_step[6] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $group = ""; $dbname = "rha_count_record"; $step = 7; $_step[7] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '综合统计-流程综合统计'; $Subject = '本月-合并'; $Description = '综合统计-流程综合统计(本月-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "流程"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 20, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($data['xv'] as $key => $val) { if ($_step[$key][0]['total'] != '') { $m = "(" . round($_step[$key + 1][0]['total'] / $_step[$key][0]['total'] * 100, 2) . "%)"; } $XPhpExcel->setValue("A" . ($key + 2), $val); $XPhpExcel->setValue("B" . ($key + 2), strval($_step[$key + 1][0]['total'] . $m . " ")); } //清空输出缓存 ob_clean(); $XPhpExcel->output($date . "/" . $Description); unset($XPhpExcel); //销毁 break; default: $dateSearch = reqstr("dateSearch", ""); $datastatus = reqnum("datastatus", 1); $stationC = reqstr("stationC"); $stationC = explode(",", $stationC); $stationChoice = array(); if ($stationC == array()) { //若为空则为不排除站点 foreach ($station['allrow'] as $key => $val) { $stationChoice[] = $val['id']; //选中的站点 } } else { foreach ($station['allrow'] as $key => $val) { if (in_array($val['id'], $stationC)) { $stationChoice[] = $val['id']; //选中的站点 } } } switch ($dateSearch) { case "oneday": $date = reqstr("oneday"); $group = ""; $dbname = "rha_wifi_daily"; $step = 1; $_step[1] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $date = date("Y_m_d", strtotime($date)); $group = ""; $dbname = "rha_count_record"; $step = 2; $_step[2] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 3; $_step[3] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 4; $_step[4] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 5; $_step[5] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 6; $_step[6] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 7; $_step[7] = $PSys_ComprehensiveModel->getDay($date, $group, $dbname, $step, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '综合统计-流程综合统计'; $Subject = '单日-合并'; $Description = '综合统计-流程综合统计(单日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "流程"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 20, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($data['xv'] as $key => $val) { if ($_step[$key][0]['total'] != '') { $m = "(" . round($_step[$key + 1][0]['total'] / $_step[$key][0]['total'] * 100, 2) . "%)"; } $XPhpExcel->setValue("A" . ($key + 2), $val); $XPhpExcel->setValue("B" . ($key + 2), strval($_step[$key + 1][0]['total'] . $m . " ")); } //清空输出缓存 ob_clean(); $XPhpExcel->output(str_replace("_", "-", $date) . "/" . $Description); unset($XPhpExcel); //销毁 break; case "manyday": $bdate = reqstr("bmanyday"); $edate = reqstr("emanyday"); //计算天数差 $Days = round((strtotime($edate) - strtotime($bdate)) / 3600 / 24); $group = ""; $dbname = "rha_wifi_daily"; $step = 1; $_step[1] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $bdate = str_replace("-", "_", $bdate); $edate = str_replace("-", "_", $edate); $group = ""; $dbname = "rha_count_record"; $step = 2; $_step[2] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 3; $_step[3] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 4; $_step[4] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 5; $_step[5] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 6; $_step[6] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $group = ""; $dbname = "rha_count_record"; $step = 7; $_step[7] = $PSys_ComprehensiveModel->getDays($bdate, $edate, $group, $dbname, $step, $stationChoice); $XPhpExcel = new XPhpExcel(); $Creator = "statis.rockhippo.com"; $LastModifiedBy = $Creator; $Title = '综合统计-流程综合统计'; $Subject = '多日-合并'; $Description = '综合统计-流程综合统计(多日-合并)'; $Keywords = $Description; $Category = $Description; $XPhpExcel->setBasicAttr($Creator, $LastModifiedBy, $Title, $Subject, $Description, $Keywords, $Category); $XPhpExcel->setSheet(0, $Subject); $XPhpExcel->setValue("A1", "流程"); $XPhpExcel->setValue("B1", "人数"); $XPhpExcel->setWidth("A", 20, 2); $XPhpExcel->setWidth("B", 20, 2); foreach ($data['xv'] as $key => $val) { if ($_step[$key][0]['total'] != '') { $m = "(" . round($_step[$key + 1][0]['total'] / $_step[$key][0]['total'] * 100, 2) . "%)"; } $XPhpExcel->setValue("A" . ($key + 2), $val); $XPhpExcel->setValue("B" . ($key + 2), strval($_step[$key + 1][0]['total'] . $m . " ")); } //清空输出缓存 ob_clean(); $XPhpExcel->output(str_replace("_", "/", $bdate) . "~" . str_replace("_", "/", $edate) . "/" . $Description); unset($XPhpExcel); //销毁 break; } } }