You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/03/22 23:25:11 UTC

DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

           Summary: XSSFColor.getRgb() always returns null
           Product: POI
           Version: 3.6
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: mkbitbucket@mac.com


Created an attachment (id=25167)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25167)
Example file with font and background colors

When examining an XLSX file created with Microsoft Excel that has both font
colors and background colors in it, those colors cannot be extracted because
the XSSFColor method always returns null.

1) Open the attached XLSX file (or any XLSX file that has a font color or fill
color)
2) Navigate the sheet to one of the cells with color
3) Get that cell's style and font and notice that the getXSSFColor() method
returns non-null XSSFColor
4) Call getRgb() on the XSSFColor and receive null value in return

An array with the RGB values should be returned.

To make this bug more painful, I have been unable to find any workaround.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 48962] XSSFColor.getRgb() always returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

--- Comment #3 from Nick Burch <ni...@alfresco.com> 2010-05-19 05:25:23 EDT ---
I'd suggest you try un-zipping the problem file, and taking a look at the XML
that makes it up. See if you can spot where the colour details are being
recorded, then compare that with what POI is doing to spot where the issue
comes from

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by MSB <ma...@tiscali.co.uk>.
Thanks Nick. The weather forecast looks pretty poor so no more work on the
pond (ironically) and the rugby has finished (which is a relief as the
England team played so badly I cannot begin to explain) so I will take a
look over the weekend.

Yours

Mark B


Nick Burch-11 wrote:
> 
> On Wed, 24 Mar 2010, MSB wrote:
>> Do you know how xmlbeans 'decides' whether or not it ought to create a 
>> method as it parses the xsds? Does it assume that an element or 
>> attribute should be represented by a method?
> 
> I think it tends to create a method for all the attributes, but I don't 
> know for sure. Docs are at http://xmlbeans.apache.org/ if you have a 
> couple of hours to kill and fancy learning the nitty gritty details! :)
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DO-NOT-REPLY--Bug-48962--New%3A-XSSFColor.getRgb%28%29-always-returns-null-tp27993612p28032007.html
Sent from the POI - Dev mailing list archive at Nabble.com.


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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 24 Mar 2010, MSB wrote:
> Do you know how xmlbeans 'decides' whether or not it ought to create a 
> method as it parses the xsds? Does it assume that an element or 
> attribute should be represented by a method?

I think it tends to create a method for all the attributes, but I don't 
know for sure. Docs are at http://xmlbeans.apache.org/ if you have a 
couple of hours to kill and fancy learning the nitty gritty details! :)

Nick

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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by MSB <ma...@tiscali.co.uk>.
Thanks for that Nick. This is quite an odd problem as I have had a look at
the xml and sure enough colours are expressed using the sort of RGB notation
I am familiar with from the dark old days of html. What I do not know for
sure however is how the background colour for the cell is defined within the
interlinked series of files in the .xlsx archive. As a result, I cannot be
certain that I am looking at the element that affects the background colour
of a specific cell when I am searching through the xml.

Do you know how xmlbeans 'decides' whether or not it ought to create a
method as it parses the xsds? Does it assume that an element or attribute
should be represented by a method?

Yours

Mark B


Nick Burch-11 wrote:
> 
> On Tue, 23 Mar 2010, MSB wrote:
>> I do not know if the developers of POI have access to the source for the 
>> ooxml-schemas archive as I believe it is developed by another group of 
>> programmers. It may be that the only way to definitively answer your 
>> question is to forward it to those people.
> 
> It's automatically generated using xmlbeans from the microsoft/ecma 
> published xsds for the file formats
> 
> Probably the first thing to do is to create a suitable document, unzip it, 
> and see what actually got written to the file!
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DO-NOT-REPLY--Bug-48962--New%3A-XSSFColor.getRgb%28%29-always-returns-null-tp27993612p28018264.html
Sent from the POI - Dev mailing list archive at Nabble.com.


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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 23 Mar 2010, MSB wrote:
> I do not know if the developers of POI have access to the source for the 
> ooxml-schemas archive as I believe it is developed by another group of 
> programmers. It may be that the only way to definitively answer your 
> question is to forward it to those people.

It's automatically generated using xmlbeans from the microsoft/ecma 
published xsds for the file formats

Probably the first thing to do is to create a suitable document, unzip it, 
and see what actually got written to the file!

Nick

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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by MSB <ma...@tiscali.co.uk>.
Earlier this morning, I had the chance to play with some code and now that I
am having a break at work, can post this message to you.

Though I am not one of the developers of the API and cannot offer any direct
help, I have been doing a little digging around and have found that the
problem may not lie with POI but with one of the dependencies; a library
that the project relies upon. In this case it is the ooxml-schemas-1.0.jar.

Looking through the source code for the XSSFColor class, I found that the
getRgb() method looks like this;

    /**
     * Standard Alpha Red Green Blue ctColor value (ARGB).
     */
    public byte[] getRgb() {
		return ctColor.getRgb();
    }

which, as you can see, simply returns the result of calling the getRgb()
method on a local instance variable called ctColor. This variable holds a
reference to an instance of the
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor class which is
defined within that archive I mentioned earlier.

Like you, I found that the call to the getRgb() method on my XSSFColor
object returned null so I decided to take matters a little further. The
first thing I did was to call the getCTColor() method on an instance of the
XSSFColor class so that I could call the CTColor classes getRgb() method
directly and this also resulted in the returne value of null. Once I had
that CTColor class instance in hand, I noticed other methods and one of
these piqued my intertest, isSetRgb() which is declared to return a boolean
value. As I do not have the source for the CTColor class at hand I cannot be
certain about what this method does but it does not seem unreasonable to
assume it will indicate whether the colour of the cell has been set using
the traditional RGB values. Interestingly, if I call that method, it returns
false so the question that springs to my mind is, does this mean that the
cells colour is not available as an RGB value? I had simply selected the
colour from the Excel colour picker and can not be sure how this would be
encoded within the xml that describes the worksheet. Just for reference,
here is the code I played with;

public static void main(String[] args) {
        File inputFile = null;
        File outputFile = null;
        FileInputStream fis = null;
        FileOutputStream fos = null;
        XSSFWorkbook workbook = null;
        XSSFSheet sheet = null;
        XSSFRow row = null;
        XSSFCell cell = null;
        XSSFCellStyle style = null;
        XSSFColor color = null;

        try {

            inputFile = new File("C:/temp/Colour Test.xlsx");
            fis = new FileInputStream(inputFile);
            
            workbook = new XSSFWorkbook(fis);

            sheet = workbook.getSheetAt(0);
            row = sheet.getRow(0);
            cell = row.getCell(0);
            style = cell.getCellStyle();
            color = style.getFillBackgroundXSSFColor();

            System.out.println(color.getRgb());

            org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor
                 ctColor = color.getCTColor();

            System.out.println(ctColor.getRgb());

            System.out.println(ctColor.isSetRgb());

            fis.close();
        }
        catch(IOException ioEx) {
            System.out.println("Caught an: " + ioEx.getClass().getName());
            System.out.println("Message: " + ioEx.getMessage());
            System.out.println("Stacktrace follows:.....");
            ioEx.printStackTrace(System.out);
        }

I do not know if the developers of POI have access to the source for the
ooxml-schemas archive as I believe it is developed by another group of
programmers. It may be that the only way to definitively answer your
question is to forward it to those people.

Yours

Mark B


Bugzilla from bugzilla@apache.org wrote:
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=48962
> 
>            Summary: XSSFColor.getRgb() always returns null
>            Product: POI
>            Version: 3.6
>           Platform: Macintosh
>         OS/Version: Mac OS X 10.4
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: XSSF
>         AssignedTo: dev@poi.apache.org
>         ReportedBy: mkbitbucket@mac.com
> 
> 
> Created an attachment (id=25167)
>  --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25167)
> Example file with font and background colors
> 
> When examining an XLSX file created with Microsoft Excel that has both
> font
> colors and background colors in it, those colors cannot be extracted
> because
> the XSSFColor method always returns null.
> 
> 1) Open the attached XLSX file (or any XLSX file that has a font color or
> fill
> color)
> 2) Navigate the sheet to one of the cells with color
> 3) Get that cell's style and font and notice that the getXSSFColor()
> method
> returns non-null XSSFColor
> 4) Call getRgb() on the XSSFColor and receive null value in return
> 
> An array with the RGB values should be returned.
> 
> To make this bug more painful, I have been unable to find any workaround.
> 
> -- 
> Configure bugmail:
> https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DO-NOT-REPLY--Bug-48962--New%3A-XSSFColor.getRgb%28%29-always-returns-null-tp27993612p28000157.html
Sent from the POI - Dev mailing list archive at Nabble.com.


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


Re: DO NOT REPLY [Bug 48962] New: XSSFColor.getRgb() always returns null

Posted by MSB <ma...@tiscali.co.uk>.
Have been playng about with some code recently because I was trying to track
down that part of the API where the raw xml is parsed. Sadly, that came to
nought as I was confronted with factory methods that I could not 'hack' in
order to track which concrete call instances were created; these factory
methods were in compiled classes within archives and I did not have access
to the source sadly.

So, I returned to the xml and had a second look. It was at that point that I
saw something a little confusing. I believed I had been setting the
background colour of the cell but that value was not recorded at all in the
xml. What was recorded was the rgb value for the cells foreground colour and
this value was returned correctly when i called the getRgb method on the
XSSFColor object returned by calling the getFillForegroundXSSFColor() method
on the cells style. So, it may be the case that you are trying to
interrogate the wrong object.

Yours

Mark B


Bugzilla from bugzilla@apache.org wrote:
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=48962
> 
>            Summary: XSSFColor.getRgb() always returns null
>            Product: POI
>            Version: 3.6
>           Platform: Macintosh
>         OS/Version: Mac OS X 10.4
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: XSSF
>         AssignedTo: dev@poi.apache.org
>         ReportedBy: mkbitbucket@mac.com
> 
> 
> Created an attachment (id=25167)
>  --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25167)
> Example file with font and background colors
> 
> When examining an XLSX file created with Microsoft Excel that has both
> font
> colors and background colors in it, those colors cannot be extracted
> because
> the XSSFColor method always returns null.
> 
> 1) Open the attached XLSX file (or any XLSX file that has a font color or
> fill
> color)
> 2) Navigate the sheet to one of the cells with color
> 3) Get that cell's style and font and notice that the getXSSFColor()
> method
> returns non-null XSSFColor
> 4) Call getRgb() on the XSSFColor and receive null value in return
> 
> An array with the RGB values should be returned.
> 
> To make this bug more painful, I have been unable to find any workaround.
> 
> -- 
> Configure bugmail:
> https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DO-NOT-REPLY--Bug-48962--New%3A-XSSFColor.getRgb%28%29-always-returns-null-tp27993612p28085329.html
Sent from the POI - Dev mailing list archive at Nabble.com.


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


DO NOT REPLY [Bug 48962] XSSFColor.getRgb() always returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

--- Comment #5 from Nick Burch <ni...@alfresco.com> 2010-05-20 04:48:27 EDT ---
It's an auto-generated jar, based on the microsoft XSDs. See the list archive
for many discussions on how to get the generated source.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 48962] XSSFColor.getRgb() always returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

longxibo@sina.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from longxibo@sina.com 2010-05-19 04:50:35 EDT ---
(In reply to comment #1)
> You can see this:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=48432

But org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme and
ThemeDocument can not found in poi-ooxml-schemas-3.6-20091214.jar

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 48962] XSSFColor.getRgb() always returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

--- Comment #4 from longxibo@sina.com 2010-05-19 22:03:55 EDT ---
(In reply to comment #3)
> I'd suggest you try un-zipping the problem file, and taking a look at the XML
> that makes it up. See if you can spot where the colour details are being
> recorded, then compare that with what POI is doing to spot where the issue
> comes from

Ok,Where I can download poi-ooxml-schemas-3.6-20091214.jar corresponding source
code? So I add new ThemeDocument and CTColorScheme Class into
poi-ooxml-schemas-3.6 project.Thank you very much!

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 48962] XSSFColor.getRgb() always returns null

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48962

--- Comment #1 from Petr.Udalau <Pe...@exigenservices.com> 2010-03-31 13:04:06 UTC ---
You can see this:
https://issues.apache.org/bugzilla/show_bug.cgi?id=48432

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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