-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.php
92 lines (71 loc) · 2.79 KB
/
index2.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
include('connect.php');
echo "Hello";
require('PHPExcel.php');
$phpExcel = new PHPExcel;
// Set default font to Arial
$phpExcel->getDefaultStyle()->getFont()->setName('Arial');
// Set default font size to 12
$phpExcel->getDefaultStyle()->getFont()->setSize(12);
// Set spreadsheet properties – title, creator and description
$phpExcel ->getProperties()->setTitle("Product list");
$phpExcel ->getProperties()->setCreator("Voja Janjic");
$phpExcel ->getProperties()->setDescription("PHP Excel spreadsheet testing.");
// Create the PHPExcel spreadsheet writer object
// We will create xlsx file (Excel 2007 and above)
$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");
// When creating the writer object, the first sheet is also created
// We will get the already created sheet
$sheet = $phpExcel ->getActiveSheet();
// Set sheet title
$sheet->setTitle('My product list');
// Create spreadsheet header
$sheet ->getCell('A1')->setValue('faculty name');
$sheet ->getCell('B1')->setValue('shortname');
$sheet ->getCell('C1')->setValue('batch');
$sheet ->getCell('D1')->setValue('subject');
$sheet ->getCell('E1')->setValue('class_no');
$sheet ->getCell('F1')->setValue('lab_no');
$sheet ->getCell('G1')->setValue('day');
// Make the header text bold and larger
$sheet->getStyle('A1:H1')->getFont()->setBold(true)->setSize(14);
$retrive = mysqli_query($con,"SELECT * FROM `timetable`;");
$i = 2;
while($data=mysqli_fetch_assoc($retrive))
{
$id = $data['Id'];
$que = $data['faculty_name'];
$f_short_name = $data['f_short_name'];
$batch_no = $data['Batch_no'];
$subject = $data['Subject'];
$flag = $data['flag'];
$class_no = $data['Class_no'];
$lab_no = $data['Lab_no'];
$day = $data['Day'];
$lecture = $data['Lecture'];
$lab = $data['Lab'];
$sheet ->getCell('A'.$i)->setValue($que);
$sheet ->getCell('B'.$i)->setValue($f_short_name);
$sheet ->getCell('C'.$i)->setValue($batch_no);
$sheet ->getCell('D'.$i)->setValue($subject);
$sheet ->getCell('E'.$i)->setValue($class_no);
$sheet ->getCell('F'.$i)->setValue($lab_no);
$sheet ->getCell('G'.$i)->setValue($day);
$i++;
}
// Autosize the columns
$sheet->getColumnDimension('A')->setAutoSize(true);
$sheet->getColumnDimension('B')->setAutoSize(true);
$sheet->getColumnDimension('C')->setAutoSize(true);
$sheet->getColumnDimension('D')->setAutoSize(true);
$sheet->getColumnDimension('E')->setAutoSize(true);
$sheet->getColumnDimension('F')->setAutoSize(true);
$sheet->getColumnDimension('G')->setAutoSize(true);
// Save the spreadsheet
$writer->save('products.xlsx');
/*ob_end_clean();
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="file.xlsx"');
header('Cache-Control: max-age=0');
$writer->save('php://output'); */
?>