Bug 60462

Summary: indexedColors not extracted when stored in styles.xml
Product: POI Reporter: bknippen
Component: XSSFAssignee: POI Developers List <dev>
Status: NEW ---    
Severity: normal CC: bknippen
Priority: P2    
Version: 3.15-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: example workbook

Description bknippen 2016-12-09 21:21:33 UTC
Created attachment 34513 [details]
example workbook

The attached spreadsheet originally created with an earlier Excel, but recently modified, has a fill foreground set for A1 on 'mixed' sheet.

from sheet1.xml:

<c r="A1" s="2" t="s">

from styles.xml

Here is xf #2:

		<xf numFmtId="0" fontId="4" fillId="43" borderId="0" xfId="0" applyFont="1" applyFill="1" applyProtection="1">
			<protection hidden="1"/>
		</xf>


Here is fill #43:

			<patternFill patternType="solid">
				<fgColor indexed="8"/>
				<bgColor indexed="64"/>
			</patternFill>

and here are the first 8 indexedColors:

	<colors>
		<indexedColors>
			<rgbColor rgb="00000000"/>
			<rgbColor rgb="00FFFFFF"/>
			<rgbColor rgb="00FF0000"/>
			<rgbColor rgb="0000FF00"/>
			<rgbColor rgb="000000FF"/>
			<rgbColor rgb="00FFFF00"/>
			<rgbColor rgb="00FF00FF"/>
			<rgbColor rgb="0000FFFF"/>
			<rgbColor rgb="00FF00FF"/>

The correct color here is 00FF00FF (magenta), and that is what any version of excel shows when reading this wb. However, using getFillForegroundColor() on XSSFCellFill returns '00000000' because it simply looks it up in the indexedColors enum. But that enum only describes the default indexedColors. If indexedColors is stored in the wb, those should be used during extraction
Comment 1 Dominik Stadler 2017-01-02 20:46:35 UTC
It seems support for this is completely absent currently, i.e. the CTIndexedColors item is not read in StylesTable at all, currently a fixed set of indexed colors is used in ExtendedColor.getRGBOrARGB().

So the first step is likely to add support for these to class StylesTable so that we read a custom list of indexed colors and then adjust the places where the mapping from indexed colors to RGB should take place.

Patches welcome!