 colour as an RGB value (e.g. FF00CCCC or CCDDEE
     * @param    boolean        $hex        Flag indicating whether the component should be returned as a hex or a
     *                                    decimal value
     * @return    string        The red colour component
     */
    public static function getRed($RGB, $hex = true)
    {
        return self::getColourComponent($RGB, strlen($RGB) - 6, $hex);
    }

    /**
     * Get the green colour component of an RGB value
     *
     * @param    string        $RGB        The colour as an RGB value (e.g. FF00CCCC or CCDDEE
     * @param    boolean        $hex        Flag indicating whether the component should be returned as a hex or a
     *                                    decimal value
     * @return    string        The green colour component
     */
    public static function getGreen($RGB, $hex = true)
    {
        return self::getColourComponent($RGB, strlen($RGB) - 4, $hex);
    }

    /**
     * Get the blue colour component of an RGB value
     *
     * @param    string        $RGB        The colour as an RGB value (e.g. FF00CCCC or CCDDEE
     * @param    boolean        $hex        Flag indicating whether the component should be returned as a hex or a
     *                                    decimal value
     * @return    string        The blue colour component
     */
    public static function getBlue($RGB, $hex = true)
    {
        return self::getColourComponent($RGB, strlen($RGB) - 2, $hex);
    }

    /**
     * Adjust the brightness of a color
     *
     * @param    string        $hex    The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
     * @param    float        $adjustPercentage    The percentage by which to adjust the colour as a float from -1 to 1
     * @return    string        The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
     */
    public static function changeBrightness($hex, $adjustPercentage)
    {
        $rgba = (strlen($hex) == 8);

        $red = self::getRed($hex, false);
        $green = self::getGreen($hex, false);
        $blue = self::getBlue($hex, false);
        if ($adjustPercentage > 0) {
            $red += (255 - $red) * $adjustPercentage;
            $green += (255 - $green) * $adjustPercentage;
            $blue += (255 - $blue) * $adjustPercentage;
        } else {
            $red += $red * $adjustPercentage;
            $green += $green * $adjustPercentage;
            $blue += $blue * $adjustPercentage;
        }

        if ($red < 0) {
            $red = 0;
        } elseif ($red > 255) {
            $red = 255;
        }
        if ($green < 0) {
            $green = 0;
        } elseif ($green > 255) {
            $green = 255;
        }
        if ($blue < 0) {
            $blue = 0;
        } elseif ($blue > 255) {
            $blue = 255;
        }

        $rgb = strtoupper(
            str_pad(dechex($red), 2, '0', 0) .
            str_pad(dechex($green), 2, '0', 0) .
            str_pad(dechex($blue), 2, '0', 0)
        );
        return (($rgba) ? 'FF' : '') . $rgb;
    }

    /**
     * Get indexed color
     *
     * @param    int            $pIndex            Index entry point into the colour array
     * @param    boolean        $background        Flag to indicate whether default background or foreground colour
     *                                            should be returned if the indexed colour doesn't exist
     * @return    PHPExcel_Style_Color
     */
    public static function indexedColor($pIndex, $background = false)
    {
        // Clean parameter
        $pIndex = intval($pIndex);

        // Indexed colors
        if (is_null(self::$indexedColors)) {
            self::$indexedColors = array(
                    1    => 'FF000000',    //    System Colour #1 - Black
                    2    => 'FFFFFFFF',    //    System Colour #2 - White
                    3    => 'FFFF0000',    //    System Colour #3 - Red
                    4    => 'FF00FF00',    //    System Colour #4 - Green
                    5    => 'FF0000FF',    //    System Colour #5 - Blue
                    6    => 'FFFFFF00',    //    System Colour #6 - Yellow
                    7    => 'FFFF00FF',    //    System Colour #7- Magenta
                    8    => 'FF00FFFF',    //    System Colour #8- Cyan
                    9    => 'FF800000',    //    Standard Colour #9
                    10    => 'FF008000',    //    Standard Colour #10
                    11    => 'FF000080',    //    Standard Colour #11
                    12    => 'FF808000',    //    Standard Colour #12
                    13    => 'FF800080',    //    Standard Colour #13
 