...
|
...
|
@@ -107,7 +107,7 @@ class Dashboard extends Backend |
|
|
}
|
|
|
|
|
|
|
|
|
//自定义导出
|
|
|
|
|
|
public function exportDayInner()
|
|
|
{
|
|
|
//月 起止时间戳
|
...
|
...
|
@@ -139,42 +139,43 @@ class Dashboard extends Backend |
|
|
$data[$k]['WRound'] = $WRound . '%';
|
|
|
}
|
|
|
}
|
|
|
$table = '';
|
|
|
$table .= "<table>
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<th class='name'>站点</th>
|
|
|
<th class='name'>报修单数量</th>
|
|
|
<th class='name'>报修完成率</th>
|
|
|
<th class='name'>报修未完成率</th>
|
|
|
<th class='name'>故障设备名称</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>";
|
|
|
foreach ($data as $v) {
|
|
|
$table .= "<tr>
|
|
|
<td class='name'>{$v['zhandian_name']}</td>
|
|
|
<td class='name'>{$v['baoxiu_num']}</td>
|
|
|
<td class='name'>{$v['Round']}</td>
|
|
|
<td class='name'>{$v['WRound']}</td>
|
|
|
<td class='name'>{$v['BaoXiuStr']}</td>
|
|
|
</tr>";
|
|
|
$filename = "用户测评数据";
|
|
|
vendor('PHPExcel.PHPExcel');
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
|
//设置保存版本格式
|
|
|
$objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
|
|
|
//设置表头
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', '站点');
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', '报修单数量');
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C1', '报修完成率');
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D1', '报修未完成率');
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E1', '故障设备名称');
|
|
|
|
|
|
//改变此处设置的长度数值
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
|
|
//输出表格
|
|
|
foreach ($data as $key => &$val) {
|
|
|
$count = Db::name('applet_answer')->where(['uid' => $val['id'], 'isdelete' => 0])->count();
|
|
|
$i = $key + 2;//表格是从2开始的
|
|
|
if ($count >= 1) {
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $val['zhandian_name']);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $val['baoxiu_num']);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $val['Round']);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $val['WRound']);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $val['BaoXiuStr']);
|
|
|
}
|
|
|
}
|
|
|
$table .= "</tbody>
|
|
|
</table>";
|
|
|
//通过header头控制输出excel表格
|
|
|
$write = new \PHPExcel_Writer_Excel5($table);
|
|
|
header("Pragma: public");
|
|
|
header("Expires: 0");
|
|
|
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
|
|
|
header("Content-Type:application/force-download");
|
|
|
header("Content-Type:application/vnd.ms-execl");
|
|
|
header("Content-Type:application/octet-stream");
|
|
|
header("Content-Type:application/download");;
|
|
|
header('Content-Disposition:attachment;filename="入库明细表.xls"');
|
|
|
header("Content-Type:application/download");
|
|
|
header('Content-Disposition:attachment;filename=' . $filename . '.xls');
|
|
|
header("Content-Transfer-Encoding:binary");
|
|
|
// echo $table;
|
|
|
$write->save('php://output');
|
|
|
$objWriter->save('php://output');
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|