-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
27 lines (20 loc) · 823 Bytes
/
index.php
File metadata and controls
27 lines (20 loc) · 823 Bytes
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
<?php
require 'vendor/autoload.php';
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$spreadsheet = $reader->load('grades_template.xlsx');
// Get sheet Select values
$sheet = $spreadsheet->getSheetByName('Select values');
// Select data from row 2
$data = $sheet->rangeToArray('B2:N2')[0];
$alphas = range('B', 'N');
$promo = 'LPDWEB';
$promoCell = $alphas[array_search($promo, $data)];
$subjects = ['Math', 'English', 'Science', 'History', 'Geography', 'Biology', 'Chemistry', 'Physics', 'Music', 'Art', 'PE', 'Health', 'Sports', 'Other'];
// Insert subject into row B starting row 3
$row = 3;
foreach ($subjects as $subject) {
$sheet->setCellValue($promoCell . $row, $subject);
$row++;
}
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->save('grades_template_full.xlsx');