I am generating an excel sheet using PhpSpreadSheet
However, the header is dynamic as it's information taken from database. How would I loop through each letter, for example from A until necessary (based on database info) to fill each cell with its name?
As you can see, I got 4 cells filled with information which is taken from database. I didn't know that there will be 4 "tests". So how can I set the header like this, without knowing the actual length?
EDIT:
foreach($headings as $head) {
$sheet->setCellValue('A1', $head);
}
So $head
represents a test. There can be 4, 8, 9, 5, 21 tests. In this code snippet it fills the A1 cell with tests. I just want to loop from A1 until necessary1 so I can feel the cells with tests. I don't know the necessary letter as there can be any number of tests up to 31
How can I loop from A1 to X1 (X can be any letter, even AB), not knowing the actual letter X?