0

I using

PhpOffice\PhpSpreadsheet
$spreadsheet = new Spreadsheet();
/* @var $sheet \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet */

And prepare array with all data in another function. Then I put array to PhpSpreadSheet

$sheet = $spreadsheet->getActiveSheet();
$sheet->fromArray($content);

The array is new every time. I don't know beforehand how many rows there will be. I need to paint some of them. How do I pass the cells to paint directly through the array?

I tried to paint some first rows, but I can't get number of next row to paint.

$spreadsheet->getActiveSheet()->getStyle('A1')->applyFromArray($styleArray);
Nisk
  • 1,084
  • 9
  • 9
  • 2
    Can't you do `count($content)` to get the number of rows? – Jacob Mulquin Nov 29 '22 at 11:18
  • Yes I can. There are intermediate totals, and I want to highlight them in color. For example, a total of 150 lines. now I want to highlight 24, 40, 133 lines. and on the next report other line numbers. – Nisk Nov 29 '22 at 14:07
  • You could iterate through `$content` to search for specific strings, then extract the index while inside the loop. – Jacob Mulquin Nov 29 '22 at 20:42
  • Thank you for this advice! I will do it. – Nisk Nov 30 '22 at 08:55

0 Answers0