1

I'm trying to stylize the rows(fill color), using PHPExcel.

But I have a problem. There are near 100 rows, but PHPExc

el 'getStyle' doesn`t work after 30-40 rows.

I`m trying this code in the loop:

$color_start=array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FFD5D8')
        )
    );
$objPHPExcel->getActiveSheet()->getStyle('A'.$i.':AD'.$i)->applyFromArray($color_start);

Thanks.

Pavel
  • 11
  • 2
  • PHPExcel doesn't care how many rows you apply a fill colour to; but if you're applying the same style to 100 rows, then I suggest you do them all in one call, not in 100 calls.... you're applying the range to columns.... apply it to rows as well: `$objPHPExcel->getActiveSheet()->getStyle('A1:AD100')->applyFromArray($color_start);` – Mark Baker Jul 10 '15 at 08:18
  • If you're using a solid fill, you should also really be using `startcolor` rather than simply `color` in your array – Mark Baker Jul 10 '15 at 08:23
  • Yes, but I`m trying to do different colors, wich depend on conditions (color_start may change). So I can`t use $objPHPExcel->getActiveSheet()->getStyle('A1:AD100')->applyFromArray($color_sta‌​rt); – Pavel Jul 10 '15 at 08:24
  • So what does PHPExcel actually do after 30-40 rows? Does it throw an error? Does it display the wrong colour? Does it colour fill the wrong cells? Knowing what problem I'm looking for helps when trying to work out what might be going wrong..... it saves me hours if work if I know what I'm looking for, testing if I can replicate a bug – Mark Baker Jul 10 '15 at 08:26
  • So what does PHPExcel actually do after 30-40 rows? - print all data in cells correctly, but style after that doesn`t work. Does it throw an error? - There are no errors on the page and worksheet. Does it display the wrong colour? - colors fill correct. Does it colour fill the wrong cells? - no I using code bellow: http://pastebin.com/CY8jfvW1 – Pavel Jul 10 '15 at 09:07

1 Answers1

0

this problem it's because the array not configured correctly.

Retired from http://www.cmsws.com/examples/applications/phpexcel/Documentation/API/PHPExcel_Style/PHPExcel_Style_Fill.html#methodapplyFromArray

Good exemplo:

$objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
     array(
         'type'       => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
         'rotation'   => 0,
         'startcolor' => array(
             'rgb' => '000000'
         ),
         'endcolor'   => array(
             'argb' => 'FFFFFFFF'
         )
     )
);
Danieldms
  • 1,006
  • 9
  • 11