Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Border color changes based on default style. #634

Open
GreeKatrina opened this issue Aug 11, 2015 · 3 comments
Open

Border color changes based on default style. #634

GreeKatrina opened this issue Aug 11, 2015 · 3 comments

Comments

@GreeKatrina
Copy link

I render a SS based on some data I get from our DB.
How I set the default style:

private $default_style = array(
    'font' => array(
        'name' => 'Verdana',
        'color' => array('rgb' => '000000'),
        'size' => 11
    ),
    'alignment' => array(
        'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
        'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER
    ),
    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN,
            'color' => array('rgb' => 'AAAAAA')
        )
    )
);

// Later on

$this->setActiveSheetIndex(0);
$as = $this->getActiveSheet();
$as->setShowGridlines(true);
$as->getDefaultStyle()->applyFromArray($this->default_style);

I do some "every other row" styling like so:

private $odd_row_style = array(
    'fill' => array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'color' => array('rgb' => 'CCCCCC')
    ),
    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN,
            'color' => array('rgb' => 'AAAAAA')
        )
    )
);

// Later on

if ($site_count % 2 != 0) $as->getStyle('A'.$row.':'.$last_col.$row)->applyFromArray($this->odd_row_style);

Which works fine. However, my border colors are acting weird. When I set the default_style's border color to "AAAAAA", like the code above, I get this output:

screen shot 2015-08-11 at 3 22 12 pm

As you can see in rows 50 and 51, for example, the border color is the same at the fill color, instead of the border color being a little darker, like the cells in column B.

When I change the default_style's border color to black (000000), and I keep the odd_row_style border color AAAAAA, as before... I get this:

screen shot 2015-08-11 at 3 16 53 pm

It's like all of the border colors just shifted a shade darker? Rows 50 and 51 have the darker border now, how I want them, but column B's border is too dark now. I've tried changing the odd_row_style border's color to black as well, and it doesn't seem to change anything.

Is it some setting with my Excel program that is messing this up, could I possibly be doing something wrong, or is this a bug?

Thanks for your help.

@GreeKatrina
Copy link
Author

After digging some more, I realized that the outline borders are the issue. For some reason, the outline applies the default style borders, only to the left-most and right-most columns within the outline. This can be seen in the screenshot below. You can see the effect happening in my previous comment as well for the purple outline.

screen shot 2015-08-12 at 10 00 52 am

When I get rid of the outlines, the borders are still the same color as the odd rows' fill color, instead of using the slightly darker default style that was set.

screen shot 2015-08-12 at 10 04 43 am

I'm really just at a loss for what's going on here.

@GreeKatrina
Copy link
Author

The only way I could figure out how to resolve this, was to not set a border style using the ->getDefaultStyle() function. I set the border style for the cells separately using ->getStyle() for a range of cells, and things started to work as expected.

If this is the result you're expecting from this, feel free to close it. If that isn't the result you would expect, let me know if you need anymore detail.

Thanks.

@tostercx
Copy link

There is still something horribly wrong, if I set borders with getDefaultStyle for the whole workbook they aren't set and can't be overwritten by individual cell styles later on (tried with 2007 writer if that matters).

If I just use getStyle with ranges, everything works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants