-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.php
executable file
·38 lines (30 loc) · 1.18 KB
/
report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once 'lib/PHPExcel.php';
require_once 'lib/PHPExcel/IOFactory.php';
require_once 'lib/class.db.php';
error_reporting(0);
//date_default_timezone_set('America/Los_Angeles');
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->setActiveSheetIndex(0);
$sheet->setCellValue('A1', 'Student ID');
$sheet->setCellValue('B1', 'Last Name');
$sheet->setCellValue('C1', 'First Name');
$sheet->setCellValue('D1', 'Status');
$sheet->setCellValue('E1', 'Timestamp');
$db = new db();
$i = 2;
$log = $db->query("SELECT enrolled.first, enrolled.last, log.sid, log.timestamp, log.status FROM enrolled, log WHERE log.sid = enrolled.sid;");
while ($row = $db->row($log)) {
$sheet->setCellValue('A' . $i, $row['sid']);
$sheet->setCellValue('B' . $i, $row['last']);
$sheet->setCellValue('C' . $i, $row['first']);
$sheet->setCellValue('D' . $i, $row['status']);
$sheet->setCellValue('E' . $i, $row['timestamp']);
$i++;
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="report.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
?>