When you install setLandscape(true) gives an error?

Good afternoon.
Tell me what could be wrong.

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

ps.setLandscape(true);
}

Swears on the line ps.setLandscape(true);
Caused by: java.lang.NullPointerException
at org.apache.poi.hssf.usermodel.HSSFPrintSetup.setLandscape(HSSFPrintSetup.java:112)
June 27th 19 at 15:07
1 answer
June 27th 19 at 15:09
Method getPrintSetup() returned null. And null, of course, there is no method setLandscape(), hence to call it impossible.
Sergey thanks. Why is this happening? - aron commented on June 27th 19 at 15:12
: who the hell knows. May not be able to communicate with the print subsystem. Or contacted, and she replied that no printers. - samir39 commented on June 27th 19 at 15:15
throws only on some files
testing for null does not help
if (ps != null) {...} - aron commented on June 27th 19 at 15:18
getPrintSetup() returns null only on some files, example below.
Found a similar issue but how to fix I do not understand. For a week I bet with the same. And if the file is to open Excel and it and save, then everything works, tried to programmatically overwrite, change name, correct content that does not help.

https://bz.apache.org/bugzilla/show_bug.cgi?id=46548#c4"

An example file: https://wdfiles.ru/hCaX"

Thank you. - aron commented on June 27th 19 at 15:21
: maybe you should send the developers a bug report with this file? - samir39 commented on June 27th 19 at 15:24
Did

https://bz.apache.org/bugzilla/show_bug.cgi?id=60985 - aron commented on June 27th 19 at 15:27

Find more questions by tags JavaExcel