× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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);

It is necessary to set the fill style in order for the color to be shown in the cell.
</snip>


From this, it would appear that they would like you to use the HSSFCellStyle
class' 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.
Also, although I'm not sure if it matters, all examples I've seen set the fill pattern BEFORE the background colour. The docs do say: "It is necessary to set the fill style in order for the color to be shown in the cell." But there is no reference to the order.


Regarding bg - that's just the variable name. Java method signatures contain the arguments in a comma-delimited list of the form: access-modifier return-type method-name (arg1type arg1, arg2type arg2). This is a little simplified, but you get the idea.

Example: public int returnInt (String var1, String var2) could easily be written as public int returnInt (String bg1, String bg2). This just means that the java developer must reference these variable names WITHIN the method to access the passed arguments. This is of no use to anybody calling the method, it's just documented for completeness.

So bg is just the background colour variable name - the variable type is what's important to you. However, it doesn't do any harm to name your RPG prototype variables the same name - just to make it easy to cross-reference when developing/debugging.

Cheers

Larry Ducie



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.