วันอังคารที่ 22 มกราคม พ.ศ. 2562

Excel Easy Export


ສະບາຍດີ ມື້ນີ້ຈະມາສອນແລະ ນຳສະເໜີ ການຂຽນ Excel Easy Export With PHP by OOP ຈະມີຂັ້ນຕອນທີ່ງ່າຍແລະ ສາມາເຮັດຕາມໄດ້ ດັ່ງນີ້ ===================================================
<!DOCTYPE HTML>
<html>

<head>
    <title>OOP Export to Excel</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE-Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
</head>
<body>
    <style type="text/css">
body{
    font-family:'Saysettha MX',Phetsarath OT,Saysettha OT,sans-serif;
    font-size:12.5px;
    }

</style>
      <?php
        $localhost = "localhost";
        $root = "root";
        $pass = "44@44";
        $db_staffdata = "mydatabase";
              $con = new mysqli($localhost,$root,$pass,$db_staffdata);
              mysqli_query($con,"set names utf8");
                   if($con->connect_errno) {
                     echo $con->connect_error;
                     exit;
                    }
      ?>
<?php
    $filName = "Export.csv";
    $objWrite= "utf8_unicode_ci";
    $objWrite = fopen("Export.csv","w","utf8_unicode_ci");
    mb_convert_encoding($Do, 'UTF-16LE', 'UTF-8'); 
    mb_convert_encoding($SEl, 'UTF-16LE', 'UTF-8'); 
?>
<?php
    $SEl = " SELECT * FROM  user ORDER BY UserID ASC ";
    $Table = $con->query($SEl);

     fputs($objWrite, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
     fwrite($objWrite, ",\"UserID\",\"UserName\",\"Email\"\n");
        $i=0;
            while($S= $Table->fetch_assoc())
           {             
          $i++;                 
     fwrite($objWrite, ",\"$S[UserID]\",\"$S[UserName]\",\"$S[Email]\"\n");

      }                     
     fclose($objWrite);
     echo "<a href=$filName><img src='' width='40' title='Export to Excel' height='40'  class='non-printable'/></a>";
?>
</body>
</html>

===================================================
out put
Click For Download


after to Download  And Opening


Support MS 2010 to Higher Version


Result 


database, table user and fields


Bring it on !!!! ຈົບແລ້ວສຳຫລັບບົດຄວາມນີ້ ແນວທາງງ່າຍໆ ໝູ່ເພື່ອນທ່ານທີ່ສົນໃຈ ສາມາດເຂົ້າມາເບິ່ງ ຫລື ສົນໃຈໃຫ້ຂຽນບົດຄວາມໃດ ສາມາດ Comment ໄດ້ເດິ້ ຫວັງວ່າສິເປັນປະໂຫຍດແກ່ ຜູ້ເຂົ້າມາອ່ານທຸກຄົນ
























ไม่มีความคิดเห็น:

แสดงความคิดเห็น