I
I
Ivan2017-04-08 17:44:20
Java
Ivan, 2017-04-08 17:44:20

When setting setLandscape(true) gives an error?

Good afternoon.
Prompt in what there can be a business.

private void prinTTN(Document document) {
        Workbook workbook = document.getWorkbook();
        Sheet sheet = workbook.getSheetAt(0);
        HSSFPrintSetup ps = (HSSFPrintSetup) sheet.getPrintSetup();

        ps.setLandscape(true);
}

Swears at the line ps.setLandscape(true);
Caused by: java.lang.NullPointerException
at org.apache.poi.hssf.usermodel.HSSFPrintSetup.setLandscape(HSSFPrintSetup.java:112)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-04-08
@sergey-gornostaev

The getPrintSetup() method returned null. And null, of course, doesn't have a setLandscape() method, so you can't call it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question