Reputation: 153
I am converting an Excel table to HTML. I am using POI in Java to get the color of the cell in an xls workbook. The problem is that the colors don´t match: In Excel I have RGB values of 242, 220, and 219, but when I get them using POI I get RGB(255,153,204).
Any idea on how to get the exact color?
HSSFCellStyle cs = (HSSFCellStyle) style;
out.format(" /* fill pattern = %d */%n", cs.getFillPattern());
styleColorback(out, "background-color", cs.getFillForegroundColorColor())
private void styleColorback(Formatter out, String attr, HSSFColor color) {
short[] rgb = color.getTriplet();
out.format(" %s: #%02x%02x%02x; ", attr, rgb[0], rgb[1], rgb[2]);
}
Upvotes: 1
Views: 1531
Reputation: 153
I think that it isn´t possible to obtain the exact color of the cell because of Excel 2003 palette contains only 56 colors. The unique way that I found to get the exact color is that when you save the Excel format as .xls in the options of excel and then in save menu there we can change the colors of the palette for the desired color.
Upvotes: 0