How to set background color to the pivot table?

hi,


I am not able to set the below color “strColor”, but i can do standard color red,blue and green.
Please find my piece of code. Please help me on that.

String strColor="#4F81BD";
strColor=strColor.replace("#", “”);
//We need to convert Hex string to Integer
Integer intColor = Integer.parseInt(strColor, 16);
System.out.println(intColor);
Color clr = Color.fromArgb(intColor);


Cells cells = sheet.getCells();
Style style6 = cells.getStyle();
Font ff = style6.getFont();
ff.setColor(Color.fromArgb(255,255,255));
style6.setBackgroundColor(clr);
style6.setPattern(BackgroundType.SOLID);
pivotTable.format(15, 1, style6);

Thanks
Amar

Hi,


Thanks for your posting and using Aspose.Cells.

I have tested this issue with the following sample code using the latest version: Aspose.Cells for Java (Latest Version) and found, it is working fine.

Please check the source excel file used in this code, output excel file generated by it and the screenshot for your reference.

Java
Workbook wb = new Workbook(dirPath + “sample.xlsx”);
Worksheet ws = wb.getWorksheets().get(0);

Cell cell = ws.getCells().get(“G20”);

CellsFactory f = new CellsFactory();

Style s = f.createStyle();
s.setPattern(BackgroundType.SOLID);
s.setBackgroundColor(Color.fromArgb(5210557));//4F81BD

PivotTable pt = ws.getPivotTables().get(0);
pt.format(cell.getRow(), cell.getColumn(), s);

wb.save(dirPath + “output.xlsx”);