Weird problem with setting cell background color

Topics: Developer Forum
Apr 24, 2014 at 6:19 PM
Edited Apr 24, 2014 at 6:20 PM
In my code, it sets the cell background color of cells.

$objSheet->getStyle($cellIndex)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFAFAD2');

And the program should goes from G3 to L289, but error occurred at K142. This program runs fine with generating other files, but this one. I am wondering if it reaches the limit of the range (G3 to K142?). After I comment out the set color line of code, the file generates fine.
    //do entry validation and unlock the input cells for student score
    for ($column = 'G'; $column != $lastColumn; $column++) {

        for ($row = 3; $row <= $endRow; $row++) {
            $cellIndex = $column.$row;

            //data validation; only accept 1, 2, 3 or 4
            $objValidation = $objSheet->getCell($cellIndex)->getDataValidation();

            $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST );
            $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
            $objValidation->setAllowBlank(true);
            $objValidation->setShowInputMessage(true);
            $objValidation->setShowErrorMessage(true);
            $objValidation->setShowDropDown(true);
            $objValidation->setErrorTitle('Input error');
            $objValidation->setError('It has to be 1, 2, 3, 4 or x.');
            $objValidation->setPromptTitle('Pick from list');
            $objValidation->setPrompt('Please pick a value from the drop-down list.');
            $objValidation->setFormula1('"1,2,3,4,x"');

            //unlock the cell
            $objSheet->getStyle($cellIndex)->getProtection()
            ->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);

            echo $cellIndex;
            echo ' ';

            //highlight the cell
            $objSheet->getStyle($cellIndex)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFAFAD2');


            //set the border style to thin
            $objSheet->getStyle($cellIndex)->getBorders()->getAllBorders()
            ->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

        }

    }