setDescription("none");$objPHPExcel->setActiveSh">
当前位置:Gxlcms > PHP教程 > php小代码---从慢日志文件分离出日志记录并存放于excel文件中_PHP教程

php小代码---从慢日志文件分离出日志记录并存放于excel文件中_PHP教程

时间:2021-07-01 10:21:17 帮助过:8人阅读

php小代码---从慢日志文件分离出日志记录并存放于excel文件中


 
getProperties()->setTitle("export")->setDescription("none");
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
 
$titlearray = array(
    "主机信息" => 'User@Host', "查询时间" => 'Query_time', "锁表时间" => 'Lock_time'
    , "查询时检查行数" => 'Rows_examined', "读取行数" => 'Rows_read', "时间" => 'timestamp',
    "发送字节数" => 'Bytes_sent', "执行的sql" => 'sql'
);
 
$col = 0;
foreach ($titlearray as $key => $title) {
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $key);
    $col++;
}
 
$j = 2;
foreach ($slowData as $key => $sd) {
    $col = 0;
    foreach ($titlearray as $key2 => $title) {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $j, $sd[$title]);
        $col++;
    }
    $j++;
}
 
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');
// Sending headers to force the user to download the file
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="slowsql.xls"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1055412.htmlTechArticlephp小代码---从慢日志文件分离出日志记录并存放于excel文件中 ?php header(Content-type:text/html; charset=UTF-8);ini_set(max_execution_time, 10000);ini_set(memor...

人气教程排行