I would use PropertyTemplate. There is a Java Example here: https://poi.apache.org/spreadsheet/quick-guide.html#DrawingBorders

One issue with Scott's prototypes is that at POI 3.15 they started converting int constants to Enums. and at 3.17, the methods deprecated in 3.15 will be removed. Enums are simply a class and can be defined in Java as if they were just another class. You need a few other definitions to access them though.

This defines a way to retrieve a specific enum given a string.

// Enum Names
dcl-c BorderExtent_ENUM
'org.apache.poi.ss.usermodel.BorderExtent';
dcl-c BordetStyle_ENUM
'org.apache.poi.ss.usermodel.BorderStyle';

// Enum Objects
dcl-s BorderExtent
Object(*Java: BorderExtent_ENUM);
dcl-s BorderStyle
Object(*Java: BorderStyle_ENUM);

// Enum Prototypes
dcl-pr BorderExtent_valueOf
Like(BorderExtent)
ExtProc(*Java: BorderExtent__ENUM:
'valueOf')
Static;
value Like(jString) const;
end-pr;

dcl-pr BorderStyle_valueOf
Like(BorderStyle)
ExtProc(*Java: BorderStyle__ENUM:
'valueOf')
Static;
value Like(jString) const;
end-pr;

// Class Constants
dcl-c CellRangeAddress_CLASS
'org.apache.poi.ss.util.CellRangeAddress';
dcl-c PropertyTemplate_CLASS
'org.apache.poi.ss.util.PropertyTemplate';

// Objects
dcl-s CellRangeAddress
Object(*Java: CellRangeAddress_CLASS);
dcl-s PropertyTemplate
Object(*Java: PropertyTemplate_CLASS);

// Prototypes
dcl-pr new_CellRangeAddress
Like(CellRangeAddress)
ExtProc(*Java: CellRangeAddress_CLASS:
*Constructor);
firstRow Like(jint) value;
lastRow Like(jint) value;
firstCol Like(jint) value;
lastCol Like(jint) value;
end-pr;

dcl-pr new_PropertyTemplate
Like(PropertyTemplate)
ExtProc(*Java: PropertyTemplate_CLASS:
*Constructor);
end-pr;

dcl-pr PropertyTemplate_drawBorders
ExtProc(*Java:PropertyTemplate_CLASS:
'drawBorders');
range Like(CellRangeAddress) const;
type Like(BorderStyle) const;
extent Like(BorderExtent) const;
end-pr;

dcl-pr PropertyTemplate_applyBorders
ExtProc(*Java: PropertyTemplate_CLASS:
'applyBorders');
sheet Like(Sheet) const;
end-pr;




To draw single outside borders around cells B2:D4

dcl-s range Like(CellRangeAddress);
dcl-s pt Like(PropertyTemplate);
dcl-s sh Like(Sheet);
dcl-s bType Like(BorderStyle);
dcl-s bExt Like(BorderExtent);

bType = BorderStyle_valueOf(new_String('MEDIUM'));
bExt = BorderExtent_valueOf(new_String('OUTSIDE'));
range = new_CellRangeAddress(1:3:1:3);
pt = new_PropertyTemplate();
PropertyTemplate_drawBorders(pt: range: bType: bExt);
PropertyTemplate_applyBorders(pt: sh);

The same set of borders can be stamped on multiple sheets if you wish.




Mark Murphy
Atlas Data Systems
mmurphy@xxxxxxxxxxxxxxx


-----Paul Therrien <paultherrien@xxxxxxxxxxxxxxxxxx> wrote: -----
To: java400-l@xxxxxxxxxxxx
From: Paul Therrien <paultherrien@xxxxxxxxxxxxxxxxxx>
Date: 03/09/2017 03:44PM
Subject: POI / Excel and setting borders around a range of cells


Has anyone used POI to generate Excel from RPG and implemented the
RegionUtil.setBorderBottom, .setBorderTop, .etc?

I have been trying to mimic Scott Klement's HSSF prototypes and code for
this function, but I constantly failing.

It appears that there is an object RegionUtil that has methods for
setting border attributes. I am not certain how to invoke RegionUtil
and its methods.

Any help would be appreciated.

I am using POI 3.15.

Paul

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2021 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.