You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Stuart Turner <st...@turner.eu.com> on 2012/12/22 02:48:49 UTC

Is it possible to add XSSFSheet.getTabColor?

XSSFSheet has a method to set the color of a tab but it doesn't have
the ability to get the color of a tab.

I wrote a quick implementation in XSSFSheet, based on how the
setTabColor method works, but it does not obtain the sheet's tab
color.

Can someone guide me on what needs to be done in order to add this
functionality please?

Thanks

Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Is it possible to add XSSFSheet.getTabColor?

Posted by Stuart Turner <st...@turner.eu.com>.
Hi Yegor

Thanks very much for the assistance.

Stuart




On 22 December 2012 20:08, Yegor Kozlov <ye...@dinom.ru> wrote:
> The argument in setTabColor is a color index but in XSSF color can be
> set in other form: it can be either a indexed color or RGB or a color
> from theme.
> You should check what is returned by worksheet.getSheetPr().getTabColor().
>
> The implementation sketch ois something like this:
>
>     public int getTabColor(){
>         CTSheetPr pr = worksheet.getSheetPr();
>         if(pr == null || pr.isSetTabColor()) {
>             // default tab color is white
>             return IndexedColors.WHITE.index;
>         }
>         CTColor color = pr.getTabColor();
>         if(color.isSetIndexed()) {
>             return (int)color.getIndexed();
>         }  else if (color.isSetRgb()){
>             byte[] rgb = color.getRgb();
>             // find closest matching color in IndexedColors
>             // re-use logic from  HSSFPallete#findSimilarColor
>             return closetMatch;
>         } else if(color.isSetTheme()){
>             // convert to indexed color
>         }
>
>     }
>
> Yegor
>
>
> On Sat, Dec 22, 2012 at 5:48 AM, Stuart Turner <st...@turner.eu.com> wrote:
>> XSSFSheet has a method to set the color of a tab but it doesn't have
>> the ability to get the color of a tab.
>>
>> I wrote a quick implementation in XSSFSheet, based on how the
>> setTabColor method works, but it does not obtain the sheet's tab
>> color.
>>
>> Can someone guide me on what needs to be done in order to add this
>> functionality please?
>>
>> Thanks
>>
>> Stuart
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Is it possible to add XSSFSheet.getTabColor?

Posted by Yegor Kozlov <ye...@dinom.ru>.
The argument in setTabColor is a color index but in XSSF color can be
set in other form: it can be either a indexed color or RGB or a color
from theme.
You should check what is returned by worksheet.getSheetPr().getTabColor().

The implementation sketch ois something like this:

    public int getTabColor(){
        CTSheetPr pr = worksheet.getSheetPr();
        if(pr == null || pr.isSetTabColor()) {
            // default tab color is white
            return IndexedColors.WHITE.index;
        }
        CTColor color = pr.getTabColor();
        if(color.isSetIndexed()) {
            return (int)color.getIndexed();
        }  else if (color.isSetRgb()){
            byte[] rgb = color.getRgb();
            // find closest matching color in IndexedColors
            // re-use logic from  HSSFPallete#findSimilarColor
            return closetMatch;
        } else if(color.isSetTheme()){
            // convert to indexed color
        }

    }

Yegor


On Sat, Dec 22, 2012 at 5:48 AM, Stuart Turner <st...@turner.eu.com> wrote:
> XSSFSheet has a method to set the color of a tab but it doesn't have
> the ability to get the color of a tab.
>
> I wrote a quick implementation in XSSFSheet, based on how the
> setTabColor method works, but it does not obtain the sheet's tab
> color.
>
> Can someone guide me on what needs to be done in order to add this
> functionality please?
>
> Thanks
>
> Stuart
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org