| Server IP : 172.67.187.206 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/news/elearning/ |
Upload File : |
<?php
//error_reporting(E_ALL);
error_reporting(E_ALL ^ E_DEPRECATED);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Asia/Bangkok');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once 'Classes/PHPExcel.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("PHPExcel Test Document")
->setSubject("PHPExcel Test Document")
->setDescription("Test document for PHPExcel, generated using PHP classes.")
->setKeywords("office PHPExcel php")
->setCategory("Test result file");
// Add some data
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'เลขที่')
->setCellValue('B1', 'เลขประจำตัว')
->setCellValue('C1', 'ชื่อ-สกุล')
->setCellValue('D1', 'ชั้น');
// Miscellaneous glyphs, UTF-8
require 'configs/host.php';
$user_class = $_GET["user_class"];
mysql_query( "SET NAMES utf8");
$ql="SELECT * FROM `exp_users` where `user_class` LIKE '%$user_class%'";
$qr=mysql_query($ql);
$row_num=mysql_num_rows($qr);
$i = 2;
while($rs = mysql_fetch_array($qr))
{
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, '="'.$rs['number_no'].'"');
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, '="'.$rs['user_email'].'"');
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $rs['user_fullname']);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth('30');
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $rs['user_class']);
$i++;
}
mysql_close($cn);
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('student');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
$callStartTime = microtime(true);
/*
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
*/
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Student.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
// Save Excel 95 file
/*
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
*/
?>