Bug 13483 - [PATCH] getNumMergedRegions() throws NullPointerException
Summary: [PATCH] getNumMergedRegions() throws NullPointerException
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: All other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 14919 (view as bug list)
Depends on:
Reported: 2002-10-10 11:52 UTC by Jens Gerhard
Modified: 2004-11-16 19:05 UTC (History)
2 users (show)

Patch for sheet.java (376 bytes, patch)
2002-10-11 05:59 UTC, Jens Gerhard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Gerhard 2002-10-10 11:52:59 UTC

If the actual sheet has no merged cells, the member "merged" was null and the
method getNumMergedRegions() throws an exception (NullPointerException). 
I'm converting with this method excel files to html-tables and I'm using the
regions to handle colspans and rowspans for the html-table output. 

Idea for a solution:
* Add a method "hasSheetSomeRegions()" to the class Sheet.java and
HSSFSheet.java for checking the member "merged" is null 
* extends the method "geNumMergedRegions()" like this:

    public int getNumMergedRegions()
        return merged!=null ? merged.getNumAreas() : 0;

Comment 1 Andy Oliver 2002-10-10 15:35:19 UTC
supply this as a CVS diff -u patch per the instructions on the "get involved"
page and I'll apply it.  Also getMergedRegions shoud just return 0 if merged is
null.  This is a bug.
Comment 2 Jens Gerhard 2002-10-11 05:59:09 UTC
Created attachment 3423 [details]
Patch for sheet.java
Comment 3 Andy Oliver 2002-11-28 19:05:11 UTC
Applied.  Thanks!  Please cross check.  Next time remember to add yourself to
the @author tags.
Comment 4 Toshiaki Kamoshida 2002-12-04 06:17:54 UTC
*** Bug 14919 has been marked as a duplicate of this bug. ***
Comment 5 Tang Wei 2003-04-14 02:11:11 UTC
public int getNumMergedRegions()
        return merged.getNumAreas();

but "merged" now is null.