Bug 60462 - indexedColors not extracted when stored in styles.xml
Summary: indexedColors not extracted when stored in styles.xml
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.15-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-09 21:21 UTC by bknippen
Modified: 2017-01-02 20:46 UTC (History)
1 user (show)



Attachments
example workbook (12.24 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2016-12-09 21:21 UTC, bknippen
Details

Note You need to log in before you can comment on or make changes to this bug.
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!