We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Workbook palette

Hello. Can you please help me - is there is a way to recieve a color from palette after it changed?


Following example shows, that it is not working for me.

public void paletteRGB() {
Workbook workbook = new Workbook();

int[] colors = new int[] {0x00F9F9F9, 0x00F9F9F9, 0x00969696, 0x00F9F9F9, 0x00D0D0D0, 0x00ECECEC};

for(int color : colors) {
workbook.changePalette(Color.fromArgb(color), 2);
assertEquals(color, workbook.getThemeColor(2).toArgb());
}
}

Best regards. Alexey

Hi Alexey,

Thanks for your posting and using Aspose.Cells.

You can retrieve the palette colors using Workbook.getColors() property.

For example, the following code changes the palette color at index 0. It prints the color before changing the color and after changing it. As you can see, the palette color at index 0 has changed to new color.

Java


Workbook workbook = new Workbook();


int[] colors = new int[] { 0x00F9F9F9, 0x00F9F9F9, 0x00969696, 0x00F9F9F9, 0x00D0D0D0, 0x00ECECEC };


System.out.println("Before Changing: " + workbook.getColors()[0]);


workbook.changePalette(Color.fromArgb(colors[0]), 0);


System.out.println("After Changing: " + workbook.getColors()[0]);

Console Output:
Before Changing: com.aspose.cells.Color@ff000000
After Changing: com.aspose.cells.Color@f9f9f9