Answer the question
In order to leave comments, you need to log in
How to fill cells dynamically in PHPExcel?
Hello
I have this problem using PHPExcel
$sheet->setCellValue("A1", 'ФИО');
$sheet->setCellValue("B1", 'Компания');
$sheet->setCellValue("C1", 'Тест');
$sheet->setCellValue("D1", 'Результат');
$sheet->setCellValue("E1", 'Балл');
$itr = 0;
foreach($report as $key){
$sheet->setCellValue("A".($itr + 2), $key["user_name"]);
$sheet->setCellValue("B".($itr + 2), $key["company_title"]);
$sheet->setCellValue("C".($itr + 2), $key["test"]);
$sheet->setCellValue("D".($itr + 2), $key["word"]);
$sheet->setCellValue("E".($itr + 2), $key["score"]);
$itr++;
}
Answer the question
In order to leave comments, you need to log in
everything seems to be simple - we add 2 counters for the data array (1 - a letter, 2 - a number), well, we do a cycle ala
for ($i = 1, $i < count($data), $i++) {
for ($j = 1, $j < count($data[$i]), $j++) {
eсho 'Ячейка ' . $i . 'x' . $j . ': ' . $data[$i][$j];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question