Bug 48403

Summary: Color index is set incorrectly in PaletteRecord
Product: POI Reporter: Minh Tran <mobject>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: P2    
Version: 3.5-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   

Description Minh Tran 2009-12-17 00:56:35 UTC
Color color = Color.decode("#006B6B");
HSSFPalette palette = wb.getCustomPalette();
HSSFColor hssfColor = palette.findColor((byte) color.getRed(), (byte) color.getGreen(),(byte) color.getBlue());
if (hssfColor == null)
{
   palette.setColorAtIndex((short)(PaletteRecord.STANDARD_PALETTE_SIZE -1) , (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
   hssfColor = palette.getColor((short)(PaletteRecord.STANDARD_PALETTE_SIZE -1) );

....


This did not return Color that had been set to a specific index because the setColorIndex() in PaletteRecord picks wrong index. It set new color to the different index at byteIndex(the index that user wants HSSFPalette to add) - FIRST_COLOR_INDEX; (line 118 in PaletteRecord )
Comment 1 Dominik Stadler 2015-09-29 10:15:47 UTC
I could not reproduce this with the latest POI 3.13/trunk, however I am not 100% sure to have understood the problem here. 

For now there is a unit test at r1705830, please report a new bug if this is still a problem for you.