POI Java word format sheet

1

How can I assign to word that the horizontal sheet creates me ?, by default I create it vertical

XWPFDocument document = new XWPFDocument();
def doc = document.getDocument();
def body = doc.getBody();

def section = body.getSectPr();

if(!section.isSetPgSz()) {
    section.addNewPgSz();
}

def pageSize = section.getPgSz();
pageSize.setOrient(STPageOrientation.LANDSCAPE);

But I have this error:

Cannot invoke method addNewPgSz() on null object
    
asked by sirdaiz 25.06.2018 в 15:02
source

1 answer

0

You can change it this way:

Sheet sheet = document.createSheet("new sheet");
sheet.getPrintSetup().setLandscape(true);
    
answered by 25.06.2018 в 15:33