PHP Small Code---separating log records from slow log files and storing them in an Excel file _php tutorial

Source: Internet
Author: User
Tags fread

PHP Small Code---separate log records from slow log files and store them in an Excel file


 
 GetProperties ()->settitle ("Export")->setdescription ("none"); $objPHPExcel->setactivesheetindex (0); $ Objphpexcel->getactivesheet ()->getcolumndimension (' A ')->setwidth, $objPHPExcel->getactivesheet ( )->getcolumndimension (' B ')->setwidth (+), $objPHPExcel->getactivesheet ()->getcolumndimension (' C ')- >setwidth, $objPHPExcel->getactivesheet ()->getcolumndimension (' D ')->setwidth ($objPHPExcel- >getactivesheet ()->getcolumndimension (' E ')->setwidth, $objPHPExcel->getactivesheet () Getcolumndimension (' F ')->setwidth (), $objPHPExcel->getactivesheet ()->getcolumndimension (' G ') SetWidth, $objPHPExcel->getactivesheet ()->getcolumndimension (' H ')->setwidth (15);  $titlearray = Array ("host information" = ' user@host ', "query time" = ' query_time ', "lock table time" = ' lock_time ', "Check row count when querying" = ' rows_examined ', ' read rows ' = ' rows_read ', ' time ' = ' timestamp ', ' send bytes ' = ' bytes_sent ', ' Execute 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 $key 2 = $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.html www.bkjia.com true http://www.bkjia.com/PHPjc/1055412.html techarticle PHP Small Code---separate log records from slow log files and store them in an Excel file? PHP header (content-type:text/html; charset=utf-8); Ini_set (Max_execution_ Time, 10000); Ini_set (Memor ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.