|
On Sun, 5 Dec 2004, Peter Dow wrote: > > I wondered about that. The method does say (short bg), and I wasn't clear > on what "bg" meant. Okay... the following code is the Java equivalent of a prototype: void setFillBackgroundColor(short bg) The word "void" means that this method doesn't return a value. The method name (like a subproc name in RPG) is "setFillBackgroundColor" It accepts one parameter. The name of the parameter is "bg" and the data type is "short" (short integer) So, if that answers your question, the letters "bg" specify the name of the parameter. In RPG, this prototype would look be defined as follows: D HSSFCellStyle_setFillBackgroundColor... D PR ExtProc(*JAVA: D 'org.apache.poi.hssf.- D usermodel.HSSFCellStyle': D 'setFillBackgroundColor') D bg 5I 0 value See? that's all "bg" is. It's the name of the parameter. It really doesn't matter at all -- it's just there for documentation purposes. > I did try creating an HSSFColor object, but couldn't > figure out how to assign it a specific color. More reading made it look > like I have to create an HSSFColor.LIGHT_GREEN object, but in any case, > neither of those appear to be what setFillBackgroundColor is expecting as a > parameter, unless maybe it's expecing two parameters, a short integer and a > background color object. No, it's not expecting an HSSFColor object. It's expecting an index into the color palette. It's just a number. A short integer. It's not an object. To find out what the number is for light green, you look in the Javadocs for the HSSFColor.LIGHT_GREEN class. Here's the page I'm talking about: http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/util/HSSFColor.LIGHT_GREEN.html In this class, there's a named constant called "index" that contains the index in the color palette. Unfortunately, RPG can't read fields from a java class, it can only call methods, so you'll have to define your own named constant for this number in HSSF_H. So, under "Field summary" click on "index". It takes you to a rather unhelpful description that says "public static final short index". and then provides a link to "Constant Field Values." "public" means that the field is available to be read by other objects, it's not protected from view. "static" means that this field is a part of the class, and is not different for each object that you create from the class. There's just one copy. "final" means that the value can't be changed, in other words, it's a constant. "short", of course, is the data type. And "index" is the name of the field. As I said, not very helpful. click the "Constant Field Values" link and it tells you that the value of the index for light green is 42. So, after all of that long description of everything, what it boils down to is that this is what you need for light green in RPG: D LIGHT_GREEN C CONST(42) Then you pass that to the setFillForeground() and/or setFillBackground API. > If that's true, then what does the short integer > indicate? And how do I create an appropriate background color object? Yeah, the number 42 gets passed to the method as a short integer. Not an object. Just a number. Set both the foreground and background of the "fill" to ensure that the background gets green. HSSFCellStyle_setFillForegroundColor(ColHeading: LIGHT_GREEN); HSSFCellStyle_setFillPattern(ColHeading: SOLID_FOREGROUND); Blam! It turns green.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.