|
Peter,
<snip> // Aqua background HSSFCellStyle style = wb.createCellStyle(); style.setFillBackgroundColor(HSSFColor.AQUA.index); style.setFillPattern(HSSFCellStyle.BIG_SPOTS); HSSFCell cell = row.createCell((short) 1); cell.setCellValue("X"); cell.setCellStyle(style); </snip>
Here is the javadoc for the method you are working with:
<snip> setFillBackgroundColor public void setFillBackgroundColor(short bg) set the background fill color.
For example:
cs.setFillPattern(HSSFCellStyle.FINE_DOTS ); cs.setFillBackgroundColor(HSSFCellStyle.RED);
or, for the special case of SOLID_FILL:
cs.setFillPattern(HSSFCellStyle.SOLID_FILL ); cs.setFillForgroundColor(HSSFSeCellStyle.RED);
From this, it would appear that they would like you to use the HSSFCellStyleclass' public static short variable RED, rather than a red colour generated from an index within the HSSFColor class. Funnily though, I can't see RED listed as a variable for the CellStyle class. Your problem may simply be that the index of AQUA in the HSSFColor class does not match an expected colour number within the setFillBackgroundColor method in the CellStyle class. If AQUA is first in the index (highly probable) then the number returned would be 0. Maybe you simply need to use index+1.
Cheers
Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.