php小代碼---從慢記錄檔分離出日誌記錄並存放於excel檔案中_PHP教程

來源:互聯網
上載者:User

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 fileheader('Content-Type: application/vnd.ms-excel');header('Content-Disposition: attachment;filename="slowsql.xls"');header('Cache-Control: max-age=0');$objWriter->save('php://output');

http://www.bkjia.com/PHPjc/1055412.htmlwww.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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.