Php small code-separating log records from slow log files and storing them in excel files
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 ("Host information" => 'User @ host ', "Query time" => 'query _ time', "Lock table time" => 'Lock _ time', "check the number of Rows during Query" => 'rows _ examined ', "Number of read Rows" => 'rows _ read', "time" => 'timestamp', "Number of sent Bytes" => 'bytes _ sent ', "Executed 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 fileheader ('content-Type: application/vnd. ms-excel '); header ('content-Disposition: attachment; filename = "slowsql.xls"'); header ('cache-Control: max-age = 0 '); $ objWriter-> save ('php: // output ');