poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 36956] New: - NullPointerException trying to place a page break
Date Thu, 06 Oct 2005 19:45:04 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36956>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36956

           Summary: NullPointerException trying to place a page break
           Product: POI
           Version: 2.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: alex.savitsky@kraft.com


This error only happens when trying to insert page break in an existing 
workbook, like in

HSSFWorkbook book = new HSSFWorkbook(new FileInputStream(existingFileName));
HSSFSheet sheet = book.getSheetAt(0);
sheet.setRowBreak(10);

When doing same thing with a new workbook, it works:

HSSFWorkbook book = new HSSFWorkbook();
HSSFSheet sheet = book.createSheet("Test");
sheet.setRowBreak(10);

The reason is that the rowBreaks property of Sheet is only initialized for new 
sheets (the createSheet() call). If an existing sheet (createSheet(List, int, 
int) call) doesn't have any records for page breaks, then rowBreaks doesn't 
get initialized, resulting in an NPE.

Possible resolution: either initialize rowBreaks during createSheet call, or 
do a null check in setRowBreak()

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message