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
dcl-c BordetStyle_ENUM

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

// Enum Prototypes
dcl-pr BorderExtent_valueOf
ExtProc(*Java: BorderExtent__ENUM:
value Like(jString) const;

dcl-pr BorderStyle_valueOf
ExtProc(*Java: BorderStyle__ENUM:
value Like(jString) const;

// Class Constants
dcl-c CellRangeAddress_CLASS
dcl-c PropertyTemplate_CLASS

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

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

dcl-pr new_PropertyTemplate
ExtProc(*Java: PropertyTemplate_CLASS:

dcl-pr PropertyTemplate_drawBorders
range Like(CellRangeAddress) const;
type Like(BorderStyle) const;
extent Like(BorderExtent) const;

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

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

-----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.


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-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.