-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
40 lines (29 loc) · 862 Bytes
/
index.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
<!DOCTYPE html>
<html>
<body>
<?php
require 'vendor/autoload.php';
require 'student_model.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$arrayOfStudents = [
new Student('Marko Markovic', '11101/18', 8.14, 'Banja Luka'),
new Student('Nikola Nikolic', '1101/19', 9.32, 'Doboj'),
new Student('Stefan Stefanovic', '1213/17', 6.24 , 'I.Sarajevo')
];
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$i=1;
foreach($arrayOfStudents as $x){
$sheet->setCellValue("A$i", $x->index);
$sheet->setCellValue("B$i", $x->name);
$sheet->setCellValue("C$i", $x->city);
$sheet->setCellValue("D$i", $x->rating);
$i++;
}
$writer = new Xlsx($spreadsheet);
$writer->save('helloworld.xlsx');
echo 'Generisan dokument.';
?>
</body>
</html>