I believe I've found a solution. This was particularly challenging, because RDi would not pull up the methods in a number of these classes for some reason, so, I created the prototypes manually from javadocs. Things have changed radically in POI, so, it was necessary to use the java docs for my particular version (3.14) to get the right call structures.
dcl-c XSSFColor_CLASS
'org.apache.poi.xssf.usermodel.XSSFColor';
dcl-c Color_CLASS
'java.awt.Color';
DCL-PR new_XSSFColor
OBJECT(*JAVA: XSSFColor_CLASS)
EXTPROC(*JAVA : XSSFColor_CLASS
: *CONSTRUCTOR );
Color OBJECT(*JAVA : Color_CLASS);
END-PR ;
dcl-pr New_Color
object(*JAVA:Color_CLASS)
extproc(*JAVA:Color_CLASS
:*CONSTRUCTOR);
red like(jint) value;
green like(jint) value;
blue like(jint) value;
end-pr;
dcl-pr XSSF_setFillForegroundColor
extproc(*JAVA
: 'org.apache.poi.xssf.usermodel.XSSFCellStyle'
: 'setFillForegroundColor');
XSSFColor object(*JAVA: XSSFColor_CLASS);
end-pr;
dcl-s ClrObj object(*JAVA:Color_CLASS);
dcl-s XSSFColor OBJECT(*JAVA: XSSFColor_CLASS);
_________________________
Example call:
ClrObj=New_Color(200:200:200);
XSSFColor=New_XSSFColor(ClrObj);
// Create a cell style for wrapped column headings.
// These are bold and have a border line at the bottom
ColWrapped = SSWorkbook_createCellStyle(book);
ssCellStyle_setFont(ColWrapped: WhiteFont);
SSCellStyle_setWrapText(ColWrapped:*On);
SSCellStyle_setAlignment(ColWrapped: ALIGN_CENTER);
XSSF_setFillForegroundColor(ColWrapped:XSSFColor);
ssCellStyle_setFillPattern(ColWrapped: SS_PATTERN_SOLID_FOREGROUND);
callp $SetAllBorder(ColWrapped:BORDER_THIN);
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Darren Strong
Sent: Wednesday, March 20, 2019 3:57 PM
To: midrange-RPG RPG message board (rpg400-l@xxxxxxxxxxxxxxxxxx) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Custom colors in Excel with POI XSSF
I'm being asked to add some color to my RPG generated spreadsheets that call the POI Java tools to generate spreadsheets. I know how to specify some colors, using the HSSF tools that Scott Klement wrote, but, those are pre-selected colors and they're pretty horrid for things like creating alternate row colors. I need a much more muted palette.
Does anyone have an example where they have perhaps specified the RGB values of a color. If you do send an example, please also include any special prototypes you had to create to make it happen.
Thank you.
P.S.
Here is an example of what I'm doing now with the preselected colors:
RowColor(2)=COLOR_GREY_25;
RowColor(3)=COLOR_PALE_BLUE;
// Regular number
for idx1=1 to MaxColors;
RegNum(idx1) = SSWorkbook_createCellStyle(book);
SSCellStyle_setFont(RegNum(idx1): RegFont);
SSCellStyle_setAlignment(RegNum(idx1): ALIGN_RIGHT);
callp $SetColor(RegNum(idx1):RowColor(idx1));
endfor;
//**************************************************************
dcl-proc $SetColor;
//**************************************************************
dcl-pi *n;
inStyle like(ssCellStyle);
Index int(5) const;
end-pi;
//************
if Index<>0;
ssCellStyle_setFillForegroundColor(inStyle: Index);
ssCellStyle_setFillPattern(inStyle: SS_PATTERN_SOLID_FOREGROUND);
endif;
return;
end-proc;
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.